I have the following code to extend my $_SESSION[]
variables. They expire after around 2-3 hours.
I tried to extend to 22h by changing the session.gc_maxlifetime
, but im still losing my session after a couple of hours.
//start sessions
ini_set('session.gc_maxlifetime', 60*60*22); // 22h - one day
//Output just to make sure config was changed.
echo ini_get("session.gc_maxlifetime");
session_start();
How do I increase the duration of my session?
Yes, it could be: session.cookie_lifetime which by default is 0, meaning terminate on closing of browser.
If you close your client and open it again session.gc_maxlifetime doesn't matter--it only applies to non-terminated sessions.
Or, you may have calles session start somewhere else earlier, with a smaller session.gc_maxlifetime. Often frameworks set this. Repeat calls to session start do nothing to alter the session.