PHP Sessions Timing Out.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dean Richardson

    PHP Sessions Timing Out.

    Hello,

    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.
    Dean

  • John Murtari

    #2
    Re: PHP Sessions Timing Out.

    "Dean Richardson" <advertising@de anrichardson.co m> writes:
    [color=blue]
    > 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.
    >[/color]

    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
    browser).

    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.

    ---------------- PHP.INI
    ; 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_prob ability = 1
    session.gc_divi sor = 1000

    ; After this number of seconds, stored data will be seen as 'garbage' and
    ; cleaned up by the garbage collection process.
    session.gc_maxl ifetime = 10800

    ---------------------

    Hope this helps.

    John
    _______________ _______________ _______________ _______________ _______
    John Murtari Software Workshop Inc.
    jmurtari@follow ing domain 315.635-1968(x-211) "TheBook.Co m" (TM)
    Own TheBook.com today. Secure checkout and guided transfer support. No hidden fees.

    Comment

    Working...