Welcome to the JaguarPC Community
JaguarPC
Sales: (888) 338-5261
Support: (888)-551-3050
Results 1 to 2 of 2

This is a discussion on PHP sessions on a shared server in the VPS & Dedicated forum
Some of our clients complained that they get logged out from their web-based applications, even thought they haven't been idle or even logged in for ...

  1. #1
    Loyal Client thisisit3's Avatar
    Join Date
    Mar 2007
    Posts
    642

    Exclamation PHP sessions on a shared server

    Some of our clients complained that they get logged out from their web-based applications, even thought they haven't been idle or even logged in for too long, or as long as their web application states.

    I looked into this issue and after several hours of testing i came up with this:

    PHP, by default, stores session files under /tmp. The function which cleans those files is called Garbage Collection and works by looking at the mtime of those files.

    If a PHP application defines a timeout of 5 hours, then those files have a "change" (defined by the probability and divisor) of being cleaned.

    So far so good, everything works as expected.

    Until, another PHP application from another user defines a timeout of 2 hours. Then, PHP will NOT differentiate between sessions from other users and will delete EVERYONEs sessions, thus the shortest session timeout in the entire shared server will precede all others.

    so in order to solve this problem, you have to use different save paths ("session.save_path = ") for each domain you'd like a custom session timeout.

    I hope this helps others...

  2. #2
    the Windlord Gwaihir's Avatar
    Join Date
    Jun 2002
    Posts
    2,562
    Quote Originally Posted by thisisit3 View Post
    Until, another PHP application from another user defines a timeout of 2 hours. Then, PHP will NOT differentiate between sessions from other users and will delete EVERYONEs sessions, thus the shortest session timeout in the entire shared server will precede all others.
    Are you running PHP as CGI, the way JagPC run its own shared servers, or as an Apache module? In CGI, I would expect that such deletion doesn't actually succeed as the PHP processes from other users do not have the necessary rights to delete your session files.

    Either way, storing your session data in a folder of your own is IMHO always a good idea .
    Regards,

    Wim Heemskerk
    ---
    Visit MeCCG.net - Cardgaming in J.R.R. Tolkien's Middle-earth
    And Gwaihir.net - The Middle-earth CCG store

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •