Help getting a session variable to pass though to other page
Posted: Sat Mar 28, 2009 2:57 pm
Hi,
I have started a session on my index.php, and created a cart variable, to which when a user adds an item to a basket i will concatenate product id numbers so i can loop through them and display items in the basket.
the index code is as follows:
When trying to load the information from the variable into a temp $cart an error message is received:
The desired output would be 30, although it looks like the sessions are not passing through the pages, do i need to create a session id and how do i link this through to other pages to allow the variable data to remain constant throughout the session?
Thanks for any help,
I have started a session on my index.php, and created a cart variable, to which when a user adds an item to a basket i will concatenate product id numbers so i can loop through them and display items in the basket.
the index code is as follows:
Code: Select all
session_start();
$_SESSION['cart'] = 30;When trying to load the information from the variable into a temp $cart an error message is received:
Code: Select all
Notice: Undefined variable: _SESSIONCode: Select all
$cart = $_SESSION['cart'];
echo $cart;