I seem to have mutliple sessions.

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
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

I seem to have mutliple sessions.

Post by impulse() »

I have been hacking at a calendar all last week and it's come to the point now where I seem to have 2 sessions. When a user logs into the calendar it created a $_SESSION["login"] = <username> variable. But if I print_r the $_SESSION variable from another page then $_SESSION is empty. And if I assign a value to $_SESSION["test"] anywhere that <b>isn't</b> the login page then I can view it anywhere besides the login page. It's as if the login page and the rest of the calendar are seperate $_SESSION variables.

Has this problem been known before?

Regards,
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

It's not likely to be a problem with PHP, but your code or possibly your configuration choices. If you run phpinfo() what does the session section say during the login page and during another page? If you look at your cookie information regarding the session, what is the domain and path set to in each instance?
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Are you forgetting session_start() at the top of each page using the session?
impulse()
Forum Regular
Posts: 748
Joined: Wed Aug 09, 2006 8:36 am
Location: Staffordshire, UK
Contact:

Post by impulse() »

I found a function called

Code: Select all

session_name
in the code. Removing this seemed to sort the problem.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

That can most certainly help create different sessions if you're not careful. ;)
Post Reply