I’ve been trying to figure this out for a while, and it makes me go crazy. Mostly I have a form for American and Canadian users. At the bottom of the form there is a link for Canadian users, which directs users to can-sesssion.php, which contains:
<?php if (isset($_SESSION['can'])) { session_start(); session_destroy(); session_unset(); session_start(); $_SESSION['can'] = 2; } else { session_start(); $_SESSION['can'] = 1; } header('Location: '. $_SERVER['HTTP_REFERER'] . ''); ?>
Basically, if they click on the link, it sets $ _SESSION ['can'] = 1. Now there is one more option, and if they click on this link, it will return them to this page, and the session should be destroyed and a new one should be established. value (well, what should he do). The problem is that I printed $ _SESSION ['can'] and still retains this old value after going to this page. Is there a better way to do this, or is there something wrong with my code? Thanks for the help.
source share