What are common methods for sending variables in PHP?

When sending variables in PHP, common methods include using GET or POST requests, using cookies, using sessions, or using hidden form fields. Each method has its own use case and advantages depending on the specific requirements of the application.

// Using GET request to send variables
<a href="page.php?var=value">Link</a>

// Using POST request to send variables
<form method="post" action="page.php">
    <input type="hidden" name="var" value="value">
    <button type="submit">Submit</button>
</form>

// Using cookies to send variables
setcookie("var", "value", time() + 3600, "/");

// Using sessions to send variables
session_start();
$_SESSION["var"] = "value";

// Using hidden form fields to send variables
<form method="post" action="page.php">
    <input type="hidden" name="var" value="value">
    <button type="submit">Submit</button>
</form>