Session Problem
Posted: Wed Apr 21, 2004 1:10 am
Hi guys
I have a common page for navigation and member login which I have included 'include ("lhs.php")' this common page in every page in the site.
When a user browse through the site and add items to the shopping cart and try to login to the site afterwards (since the login page is a include page it appears in the shopping cart pages as well) the variables used in the shoping cart were lost.
I did some coding to store the variables as a sessions, if the variable gets a blank value (happens when user logs in and page reloads) it will take the session value in to that variable.
Problem :
When the variable recieves a blank value the session variable is also get re initialised with blank value;
//gets value from a form
$Genre = trim($_POST['Genre']);
//$Genre is blank when page reloads
if ($Genre == "") {
//get session value into $Genre variable
$Genre = $_SESSION['Genre'];
}
// set $Genre variable as a session Genre
$_SESSION['Genre'] = $Genre;
// $Genre variable holds session Genre.
//I always want to use the value taken from the session
$Genre = $_SESSION['Genre'];
Need help!
Thanks
I have a common page for navigation and member login which I have included 'include ("lhs.php")' this common page in every page in the site.
When a user browse through the site and add items to the shopping cart and try to login to the site afterwards (since the login page is a include page it appears in the shopping cart pages as well) the variables used in the shoping cart were lost.
I did some coding to store the variables as a sessions, if the variable gets a blank value (happens when user logs in and page reloads) it will take the session value in to that variable.
Problem :
When the variable recieves a blank value the session variable is also get re initialised with blank value;
//gets value from a form
$Genre = trim($_POST['Genre']);
//$Genre is blank when page reloads
if ($Genre == "") {
//get session value into $Genre variable
$Genre = $_SESSION['Genre'];
}
// set $Genre variable as a session Genre
$_SESSION['Genre'] = $Genre;
// $Genre variable holds session Genre.
//I always want to use the value taken from the session
$Genre = $_SESSION['Genre'];
Need help!
Thanks