Session variables keep resetting
Posted: Thu Apr 02, 2009 1:39 pm
Hi,
I have a problem with variables getting reset each time the main index.php is loaded should a user wish to go back to view items after adding one to the basket. I therefore added an initial check to set the default values once based on sessioncode being equal to 0, after which the variable is assigned sessionid().
Therefore now I am unable to reset the values, i have seen a function session_destroy/unset. Would this help in this situation, if I was to add a button, 'clear basket' which ran a function similar would this clear the session or at least reset the core values?
I have a problem with variables getting reset each time the main index.php is loaded should a user wish to go back to view items after adding one to the basket. I therefore added an initial check to set the default values once based on sessioncode being equal to 0, after which the variable is assigned sessionid().
Therefore now I am unable to reset the values, i have seen a function session_destroy/unset. Would this help in this situation, if I was to add a button, 'clear basket' which ran a function similar would this clear the session or at least reset the core values?
Code: Select all
$_SESSION["sessioncode"] = 0;
$sessioncode = $_SESSION["sessioncode"];
if($_SESSION["sessioncode"]=0){
$pointer = 0;
$_SESSION["pointer"] = $pointer;
}
$sessioncode = session_id();