problems with session in multiple screens

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
PingLeeQuan
Forum Commoner
Posts: 58
Joined: Tue Sep 03, 2002 8:08 am

problems with session in multiple screens

Post 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
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post 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).
User avatar
redcircle
Forum Commoner
Posts: 43
Joined: Fri Jan 31, 2003 8:47 pm
Location: michigan, usa

Post by redcircle »

Most likely the session id is stored in $_COOKIE['PHPSESSID']
bionicdonkey
Forum Contributor
Posts: 132
Joined: Fri Jan 31, 2003 2:28 am
Location: Sydney, Australia
Contact:

Post by bionicdonkey »

put session_start() on the top of all the pages
PingLeeQuan
Forum Commoner
Posts: 58
Joined: Tue Sep 03, 2002 8:08 am

Post by PingLeeQuan »

thanks for your help... that did it.
Post Reply