Do you have a question? Post it now! No Registration Necessary. Now with pictures!
- Dean Richardson
April 5, 2006, 12:18 pm
rate this thread
I am having problems with my PHP sessions timing out. I have a system
which requires the user to login. Once they login, it then stores their
username as a session variable and is checked in each page. If the
username is missing, then it makes the user log back in.
However, after 5 or 10 mins of not using the system, the user then
clicks on an option and it is prompting them to login.
At the moment this is only happening on certain computers. I generally
find that the Windows XP machines dont lose the variables easily, where
the Windows 2000 machines do.
Could this be a setting in the client or the server?
Any suggestions would help me as I've looked in the php.ini on the
server and at the IE client settings and nothing strikes me.
Thanks in Advance.
Re: PHP Sessions Timing Out.
I assume you know the session is tracked by a cookie,
and the cookie life is set by the server. I'm assuming you have
it set to zero in your php.ini (which means last as long as the
Sounds like they are expiring at random times and that
is probably a server setting, look at the session.gc_* stuff
below, especially maxlifetime. When that amount of time goes
by it is expired. If you have 'shared hosting' your provider
controls this value. They may have set a very low value to
keep from clogging the session directory with useless stuff.
That should give you a start. If that doesn't do it
you should be able to find the session cookie on most browsers
and actually see what the lifetime was set at.
; Lifetime in seconds of cookie or, if 0, until browser is restarted.
session.cookie_lifetime = 0
; Define the probability that the 'garbage collection' process is started
; on every session initialization.
; The probability is calculated by using gc_probability/gc_divisor,
; e.g. 1/100 means there is a 1% chance that the GC process starts
; on each request.
session.gc_probability = 1
session.gc_divisor = 1000
; After this number of seconds, stored data will be seen as 'garbage' and
; cleaned up by the garbage collection process.
session.gc_maxlifetime = 10800
Hope this helps.
John Murtari Software Workshop Inc.
jmurtari@following domain 315.635-1968(x-211) "TheBook.Com" (TM)
- » help me, can't find php function snmpwalk() from Web Browser
- — Previous thread in » PHP Scripting Forum