1

Hi I've been reading up on this and currently we have this as a solution:

ini_set("session.gc_maxlifetime", "28800");
ini_set('session.gc_probability',1);
ini_set('session.gc_divisor',1);
ini_set('session.cookie_lifetime','28800');  
session_set_cookie_params(86400);
session_start();

However one of my colleges have been logged out, is there another solution perhaps using session_set_cookie_params or htaccess.

BartoszKP
  • 34,786
  • 15
  • 102
  • 130
Richard Housham
  • 864
  • 2
  • 15
  • 34

2 Answers2

3

currently we have this as a solution:

To what problem? Yes you want sessions to last longer....how long?

ini_set(

Why not change the values in your php.ini that way you don't need to ensure that your code gets for every script and before calling session_start() (after all if you've got scripts which are triggering the garbage collection but DO NOT change the max_lifetime or cookie_lifetime then they'll trash the session at the expiry of the values it is using).

ini_set('session.cookie_lifetime','28800');

Sets the session cookie lifetime to 8 hours

session_set_cookie_params(86400);

Sets the session cookie lifetime to 24 hours.

If you can't be consistent between 2 adjacent lines of code....?

symcbean
  • 47,736
  • 6
  • 59
  • 94
  • I would use the php.ini but we just want it in certain areas - mainly a admin area - I'll try changing the times - that might be it. – Richard Housham Jan 10 '12 at 16:52
  • No - you can't have different session settings in different parts of the site unless you have different cookie paths and/or session identifiers. – symcbean Jan 10 '12 at 17:04
0

The main way is to extend your session_set_cookie_params value. I think 86400 is only 24 hours so after that time, the cookie will expire. Try setting it to something massive.

Sessions will then only expire when cookies are deleted from the browser.

Paul Bain
  • 4,364
  • 1
  • 16
  • 30