Desperate Help Needed With Session Problem!!!!

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

User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Desperate Help Needed With Session Problem!!!!

Post by Jade »

I run an internet game where my members are tracked by sessions. When there sessions expire they are automatically logged out of the game. However, I'm having a big problem. My sessions are not lasting for the whole hour that I've defined them to, and yes, I'm using session_start() at the top of every page. I don't know what to do!!! I'm loosing members for my game because of this and I don't want that to happen. Can anyone help me???

Jade
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

maybe some debug-infos will help?

Code: Select all

<!-- making it a comment, not everyone needs to see it 
<?php print_r(session_get_cookie_params()); ?>
-->
do the sessions expire before an hour has elapsed (and then how bad is it) or do the sessions never exist if it fails?
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Post by Jade »

The sessions start off just fine. However, after only a few minutes they seem to stop working. I keep setting the defined length of time to longer and longer but that doesn't seem to be helping at all. I'm not quite sure what the heck is going on and its driving me nuts!!!
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

is it possible that the session data files are stored in a directory that is the victim of a frantic garbage collection daemon? /tmp on some *nix-systems is more than just volatile...
I assume you've checked all parameters at http://www.php.net/manual/en/ref.session.php that effect the session(-cookie) lifetime (?)
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Post by Jade »

My sessions are in /temp but I've never had this problem before. It seems like only lately that I've been having it and i haven't done anything different than before. I have fiddled around with the session configuration in php.ini and that doesn't seem to be helping much either. I'm not quite sure whats going on... I'm completely stumped.

Jade
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

what happens if you temporarily switch to session.use_trans_sid = On?
Btw: any cookie is deleted by default when I close my browser but it also lets me change the ttl to any value I like :roll:
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Post by Jade »

I have:
session.use_trans_sid = 1
and i believe that means its on...i think...

Jade
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

if it is enabled (and used) you will notice the PHPSESSID=<something> appended to all links. If your system relies on it (because cookies are blocked or misconfigured in some way or whatever) I would check wether url_rewriter.tags contains all tags you're using. One page using a link or similar not fetched by the rewriter and the session is gone...
My sessions are in /temp
if you can reproduce the error you might keep track of one of those files. Is it deleted or the content wiped out?
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Post by Jade »

I do get PHPSESSID=<something> when you login. Like i said my sessions were working just fine a while ago. Now that I have more members on my game (10-25+ on at a single time) my members seem to be continually logged out. The only thing in the /temp that is being deleted are the sessions once they expire...only they ARE lasting for the time that they are supposed. I'm not quite sure what the heck is going on...

Jade
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

it's probably the other way round, the sessions "expire" because the data is gone.
Have you checked http://www.php.net/manual/en/ref.sessio ... axlifetime?
It might be the error occurs now because more members cause more requests that make php check more often for session-files that are considered as obsolete.
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Post by Jade »

Okay, I am on windows and it does say this:
Note: If you are using the default file-based session handler, your filesystem must keep track of access times (atime). Windows FAT does not so you will have to come up with another way to handle garbage collecting your session if you are stuck with a FAT filesystem or any other fs where atime tracking is not available.
So could that be the problem? If so, how would i come up with a way to come up with garbage collecting? Sorry, I'm still kinda new to this.

Jade
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

the refers to the filesystem used by windows.
The old FAT system (dos, win3.1, win9x ...) did not store the last time of access; if you have nt/w2k e.g. your filesystem is hopefully NTFS.
But is session.gc_maxlifetime set to something inappropriate?
(it's all guessing and gc_maxlifetime is a long shot)
User avatar
Jade
Forum Regular
Posts: 908
Joined: Sun Dec 29, 2002 5:40 pm
Location: VA

Post by Jade »

I'm on XP which is basically a newer version of NT. My session.gc_maxlifetime is set to an hour.

Jade
User avatar
SKJoy
Forum Newbie
Posts: 9
Joined: Wed Sep 29, 2004 8:34 am
Location: Dhaka, Bangladesh.
Contact:

Post by SKJoy »

u running kinda opposite trouble than of mine, still I am posting what I found assuming this might help sorting the solution out for you by others.
well, though the issue is very old, but as I could discover what really happens right now, i am posting.

this trouble is not a windows issue, but a PHP issue. it happens for the way GC is implemented in PHP.

when a request is made, PHP doesn't really check for the session time out for the requested session. instead, PHP checks the other sessions for time out & deletes the files if the session associated to that file is timed out.

so, your session will never be timed out, until another session request comes to PHP after the amount of time your session is suppose to time out.

this is not an issue any developer can solve, but this has to be solved by PHP itself (if you really find it a trouble like me, there are logics in favoure & against regarding what PHP does now). it's much like a trigger that fires to some wrong target.
denlou
Forum Newbie
Posts: 17
Joined: Fri Sep 24, 2004 7:11 pm
Location: Richmond/Vancouver, BC
Contact:

Post by denlou »

It could be possible he installed XP with Fat32, I've seen it happen to a person, poor guy.
Post Reply