Page 1 of 1

problems with session in multiple screens

Posted: Mon Feb 03, 2003 12:41 pm
by PingLeeQuan
I am trying to implement session management into our site. I have a shopping cart that requires a unique session id (used as the index into the shopping cart) for each user.

In index.php i have

session_start();
//change session name to be used part of the cookie name/value
$session.session_name('quan@twoguysco.org');

i then take the session_name and the Session_ID and create a new record in the shopping cart table.

The problem is when i go to shoppingcart.php from index.php, i try to access session_id() but it would not let me. It returns blank.

I would like to associate the person visiting shopping cart with his/her session. How can i get the session id for the user so i can pull his record from the database.

thanks a million for your help.
--quan

Posted: Mon Feb 03, 2003 5:35 pm
by volka
read http://www.php.net/manual/en/function.session-name.php
esp. note
Thus, you need to call session_name() for every request (and before session_start() or session_register() are called).

Posted: Tue Feb 04, 2003 1:52 am
by redcircle
Most likely the session id is stored in $_COOKIE['PHPSESSID']

Posted: Tue Feb 04, 2003 4:50 am
by bionicdonkey
put session_start() on the top of all the pages

Posted: Tue Feb 04, 2003 6:44 am
by PingLeeQuan
thanks for your help... that did it.