PDA

View Full Version : Timing out!


Jackie340426
12-14-2009, 06:51 AM
Hi,

I am having an issue with the CMS ...

While you are making changes it seems to timeout after a short amount of time.
Then your changes are lost?

How to fix?

Jackie340426
12-14-2009, 12:52 PM
I believe I found some info, could it be the php.ini file I have to fix?

Justin Nemeth
12-14-2009, 01:29 PM
What exactly are you doing that is causing the timeout? Uploading an image? You can try adding set_time_limit(0) to the top of the page that is timing out. More info at http://us2.php.net/set_time_limit.

-justin

Jackie340426
12-14-2009, 08:23 PM
I was inside the CMS, updating content. I went to hit save and as soon as I hit save it went back into the login screen and I lost my changes.

This web site is for a client and she said the same thing happens are her end too.
She loses her changes after a 6 minutes (I timed it). I am looking to increase the time out period, if possible.

Thanks for your help on this!!!

Martin
09-08-2010, 02:48 PM
This might be quite late for a reply. But I have recently experienced the same issue as the server session times out prematurely.

I think I have solved this by adding this piece of code to the top of all the Admin PHP pages.

<?php
$time_set = 2*60*60; // 2hrs
session_start();
?>

This give a 2 hour session before it times out and renews on any activity!

I hope this helps even though it is waaaayyy late!

Cheers,
Martin

Martin
09-08-2010, 05:28 PM
Hmm, I don't think this has worked.

So I am going to ask the web assist guys, how do you extend the default login session length for power cms?

Thanks,
Martin

Jason Byrnes
09-09-2010, 07:03 AM
session timeout is controlled by a few settings in the php.ini file.

See the following thread on the webmasterworld.com forums for details:
http://www.webmasterworld.com/forum88/12812.htm

Martin
09-09-2010, 09:56 AM
Hi Jason,

Thanks for getting back to me on this one. However, the php.ini file is not something I have access to on the server.

How do you override the settings and create your own session length?

I thought the code I posted earlier was what I needed but when I was kicked out after less than 30 minutes, I realized the session length was not being set.

Thanks,
Martin

Jason Byrnes
09-09-2010, 11:21 AM
you should be able to change the setting using ini_set. don't forget to include the set time limit function as Justin suggested also:
<?php
set_time_limit(0)
ini_set('session.cookie_lifetime',0);
ini_set('session.gc_maxlifetime',1440);
?>

neilo
09-09-2010, 11:48 AM
Hi Jason,

Thanks for the info on this. Would the code need to go at the the beginning of just the log-in page (where the session starts) or would it need to go in all pages that reference the cookie? (It seems that the standard php session gc_maxlifetime is 24 minutes (1440)]

Jason Byrnes
09-09-2010, 11:52 AM
all pages, yes the default is 1440, you can increase the number of seconds using the ini_set command

Martin
09-09-2010, 12:50 PM
Sorry I am a bit confused.

If you are referencing that I need to change the main server file php.ini, I do not have access to this. Do I?

However, if it can be changed in the admin files that I have already uploaded (and are working) on the server. Can you please specify what file(s) I need change and where?

Thanks,
Martin

Jason Byrnes
09-09-2010, 01:27 PM
If you are referencing that I need to change the main server file php.ini, I do not have access to this. Do I?

you may have access to the servers php.ini file ask your host.

many hosts allow you to create an ini file to change certain parameters an out it in the root of your site.


However, that's not I'm referring to. the code I provided can be added at line 1 of each of the admin pages to extend the session time out, you may want to change the value 1440:

ini_set('session.gc_maxlifetime',1440);


to something else like 3600 (1 hour):
ini_set('session.gc_maxlifetime',3600);

neilo
09-10-2010, 04:54 AM
Hi Jason,

<?php
set_time_limit(0)
ini_set('session.cookie_lifetime',0);
ini_set('session.gc_maxlifetime',3600);
?>

When I add the above code to my admin pages in the cms directory, lines 3 & 4 throw up 'syntax errors' in Dreamweaver, and in the browser page I get blank page and the error essage:

"Parse error: syntax error, unexpected T_STRING in /home/users/uks45031/html/katelissauer.com/cms/admin/index.php on line 3"

so I'm not sure what to do with that.

Also, I have a wordpress blog incorporated in to a site here (http://www.katelissauer.com/index.php), and the blog will stay logged in indefinitely, even after the browser is closed until you click to log out; the blog is entirely contained in the same site on the same server.

Jason Byrnes
09-10-2010, 07:13 AM
Sorry about that, missing a semicolon at the end of line 2, try:
<?php
set_time_limit(0);
ini_set('session.cookie_lifetime',0);
ini_set('session.gc_maxlifetime',3600);
?>

insttead.

It may be that the form is timing out, not the session, the set_time_limit(0); function will set the max request time to infinity

neilo
09-10-2010, 08:14 AM
Cheers Jason - will give that a go.

Thanks

Jason Byrnes
09-10-2010, 08:21 AM
you're welcome.

neilo
09-10-2010, 11:04 AM
Works perfectly - nice one!

Jason Byrnes
09-10-2010, 11:46 AM
great, glad to hear it is working.

Martin
09-13-2010, 09:30 AM
Hi Jason,

Thanks for the code, I am giving it a try right now and will report back to you how it is working.

Thanks again!