Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6880577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:59:31+00:00 2026-05-27T04:59:31+00:00

I’m having problems with the PHP site I run at work where users are

  • 0

I’m having problems with the PHP site I run at work where users are being logged out after a few minutes (the exact time varies, but it is frequent enough to be an issue), regardless of whether they have been actively using the site or not.

The difficulty is that I can’t reproduce this problem, if I login as the same users using the same browser I don’t get logged out, which suggests it is not a case of the site being completely broken. Unfortunately I don’t have access to the user machines to run any traffic-sniffing software.

The things I have already checked are:

  • Asking users to try different browsers. This doesn’t seem to solve the problem and isn’t a long-term solution anyway as I can’t dictate which browsers customers will use.
  • The server time is correct and in line with the user machines.
  • The user Apache runs as has permission to write to the session folder, and I can see the session files being created and their modification times being updated.
  • No output buffering functions are being used.
  • The problem is happening on a variety of pages which seem to have nothing in common (i.e. it’s not that they all use AJAX, or update the database or some other reason).
  • Users only access their account from one machine, i.e. they don’t do a bit of work on their laptop, switch to the desktop and then wonder why they’ve been logged out on their laptop (we don’t allow multiple simultaneous logins for the same user).

The session settings in PHP are the Debian defaults, and haven’t been changed in a .htaccess file or anywhere else. The main ones are:

session.cookie_lifetime    0
session.gc_divisor    100
session.gc_maxlifetime    1440
session.gc_probability    0
session.save_handler    files
session.save_path    /var/lib/php5
session.use_cookies    On

Debian deletes sessions through a cron job instead of using PHP’s garbage collector, which is why gc_probability is set to 0. The PHP version we’re running is: PHP 5.2.6-1+lenny13 with Suhosin-Patch 0.9.6.2 (cli) (latest version in Lenny, we’ll be upgrading to Squeeze soon but I don’t think that is the cause of the problem).

We use Zend_Session to manage sessions, and an instance of Zend_Session_Namespace is created once on every page, thus automatically calling session_start(). Sessions are cleared by calling Zend_Session::destroy() on the logout page, so the only ways a user should be logged out are:

  • If they explicitly click the logout link (we log when this happens and it doesn’t seem to be the case that browsing are pre-fetching the page and thus logging the user out).
  • If they leave the session inactive for more than 24 minutes, at which point Debian will probably delete their session (there’s a cron job which runs every half hour deleting all sessions which have been unmodified for over 24 minutes).
  • If they close the browser, as their session cookie with an expiry time of 0 will be deleted.

The checks for seeing whether a user is logged in are:

  • They have a valid session (checked by seeing whether we can access $zsession->user_id).
  • There is a row in the sessions table which has a matching user ID and session ID, and this was last updated less than an hour ago. We delete this row on logout so that even if the session still exists on disk, no one can access that account without logging in.

Can anyone suggest other things I can try?

Edit: Some additional things I have tried based on comments left:

  • Setting session.cookie_domain: This seems to have very odd behaviour in PHP. If I do not set this variable and leave it as the default of ” (empty string), then a request for http://www.domain.com will produce a cookie of http://www.domain.com. However, if I set cookie_domain to ‘www.domain.com’, the domain for the cookie is ‘.www.domain.com’ (notice leading dot, which means valid for everything below http://www.domain.com, e.g. subsite.www.domain.com).
  • Setting session.cookie_lifetime: PHP does not seem to update the expiry time on each request, so if I set cookie_lifetime to 3600 the cookie will expire one hour after the user first visits the site, even if they login and constantly use it.

Edit 2: Based on other things people have asked:

  • The site is hosted in a datacentre, on a separate VLAN. No one accessing the site is on the same network as the site.
  • There is no IP authentication used, nor is the IP address of the client used in any part of the session process (e.g. we don’t attach the session to an IP address and block the user if their next request comes from a different IP).
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:59:31+00:00Added an answer on May 27, 2026 at 4:59 am

    In the end, the answer was to just scrap sessions and write my own very simple cookie code which differs from sessions in the following ways:

    1. Stores a hash (bit like a session ID) in the database rather than in files.
    2. Sets the cookie to expire in 3600 seconds from now (updated on each page) instead of 0 seconds (the latter seemed to cause problems for IE users, although I could never replicate it).
    3. Only sends the cookie header when the user logs in or is logged in.

    It’s not an ideal situation as there’s some reinventing the wheel going on, but my small solution seems to work where PHP sessions didn’t, and having a working site is the most important thing.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want to count how many characters a certain string has in PHP, but
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I would like to count the length of a string with PHP. The string
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.