PHP sessions timeout


I have a web application that is completely behind a login wall.
Users can only view the pages when they are logged in.
It is basically a CRM system, where users of the site can enter/edit notes on different clients. It is all built by me, in PHP.

Many times someone is using the website and they begin editing a record.
It may take a long time to finish editing the record (say longer than 5 minutes).
When they finally go to click the Save button on their record/note they are editing, they get routed straight back to the login page.

I am using PHP session variables and “session_start()” at the beginning of each page.
Each page gets checked against the statement:
[php]if (!isset($_SESSION[‘user_logged_in’])) {
// not logged in, move to login page
header(“Location: login.php”);
So, for some reason that SESSION variable is empty after a certain amount of time, and the user gets routed back to the login page.

Can anyone help me find out how to fix the problem of the session logging them out in such a short amount of time? How can I extend the length of a session?

Thank you,

you can use a .htaccess file and put in there the following:

php_value session.cookie_lifetime 3600
php_value session.gc_maxlifetime 3600

Thank you for the response.
I have already setup the phprc folder/file that adds those extended session values to the code. Those are in place and I can verify that the gc_maxlifetime and cookie_lifetime are extended and in place.

The problem is that they don’t seem to help.
I was wondering if anyone knew of any other ideas, because those settings are still not stopping the users’ sessions from being logged out.

  • George

Try setting session.save_path to ~/tmp (or somewhere local).

I have the same exact problem.
My entire app requires a login and then data is persisted via a session.
My client is complaining that their sessions are ending too quickly.

sXi - obviously the op can hold a session so the tmp folder is working.
His session, like mine just times out too soon.

I’ve tried numerous variations of the solution (above) over and over and it simply DOES NOT WORK!
I’m running php 5.6.8 on Windows 7 IIS 7.

Is there any way to extend the length of a session in that environment?

Without reviewing this whole year old thread I suspect that SXI was making a suggestion relevant to shared hosting. SXI hasn’t logged in here in quite sometime, so I wouldn’t expect him to comment.

Your post is also off-topic here. This discussion forum is for customers of Dreamhost to discuss Dreamhost issues. Dreamhost doesn’t offer windows anything anywhere…