4

I am running Apache 2.2 with the latest build of PHP and mysql.

In my PHP.ini file, I can see the session timeout is set to 0, meaning the session stays live until the browser closes.

I have noticed however, that sometimes when coming in in the morning, and leaving the browser open and logged in overnight, the session seems to have expired.

Are there any other configuration settings that would be causing the session to expire? I just want to play around with the values and see what kind of time works best for my site.

Many thanks

Eds

Eds
  • 533
  • 4
  • 16
  • 35
  • 2
    You should take a look at the accepted answer from this question: http://stackoverflow.com/questions/520237/how-do-i-expire-a-php-session-after-30-minutes It might help. – Willem Jul 31 '12 at 12:04

1 Answers1

4

You can try:

http://in2.php.net/manual/en/session.configuration.php#ini.session.gc-maxlifetime

you can put this in your PHP file, second parameter is number of seconds after which data will be seen as 'garbage' and potentially cleaned up. :

ini_set('session.gc_maxlifetime', 30*60);

Hope this help!

Edit:

yes, i should mention that, thanks for pointing out.

As suggested by Willem

"call to that function has to be made before the session_start(); – Willem "

Example:

<?php

 ini_set('session.gc_maxlifetime', 30*60);
 session_start();

 ?>
metalfight - user868766
  • 2,722
  • 1
  • 16
  • 20
  • You should probably include that if you go with the ini_set(); way, that the call to that function has to be made before the session_start(); – Willem Jul 31 '12 at 12:16