How can a variable be passed through a link (a href) without using sessions in PHP?

To pass a variable through a link without using sessions in PHP, you can append the variable as a query parameter in the URL. This way, the variable will be passed through the link and can be accessed on the target page using the $_GET superglobal array.

// Source page
$variable = "value";
<a href="target_page.php?variable=<?php echo $variable; ?>">Link</a>

// Target page (target_page.php)
if(isset($_GET['variable'])){
    $variable = $_GET['variable'];
    // Use the variable as needed
}