I just installed PHP5 on a Windows server with XP SP2 and Apache 2. I am having a problem with the sessions timing out after about 30 seconds or so. I need to increase this to at least 20 minutes. The session directives are still set to the default configuration in php.ini.

session.gc_probability = 1
session.gc_divisor = 1000
session.gc_maxlifetime = 1440

Any idea why the sessions are timing out so quickly? Any other settings I should be looking at?

    session.cookie_lifetime? from the docs:

    Note: The expiration timestamp is set relative to the server time, which is not necessarily the same as the time in the client's browser.

    if you're setting it with a timestamp you must take into account the timezone.

      Thanks for the reply.

      Currently session.cookie_lifetime = 300. Should this be 0?

      Where should I get the browser timestamp to compare it to the server timestamp?

        Your cookie timeout is only 10 minutes so if there is a 9.5min discrepancy between the browser and server, this would account for the timeout.

        If you really want to get complicated, you could populate a hidden formfield via javascript using something like

        var dt = new Date();
        var gmt = dt.toGMTString();

        ... or some such (google it), so the server can know what time it is on the client... but, you're probably better off setting the timeout to 0 (default setting) so that it expires when the browser closes.

          Write a Reply...