Reputation: 1905
I am using PHP to create a website and I use session for some parts such as keeping user logged in, etc. I set the session timeout to zero, so it expires when the browser is closed. My problem is that when the webpage is opened in the browser for some time and I don't use it, the session expires! I mean when I'm not using the browser (eg. I'm editing my code, or I'm gone for lunch, etc) and after some time I go back to it and refresh it, some times it needs me to login again.
This is the method I use to start the session:
function StartSecureSession(bool $RememberMe = false) {
session_set_cookie_params(($RememberMe? 7*24*60*60 : 0), "/");
session_start();
session_regenerate_id(true);
}
Could anyone tell me what's happening? Thank you
Note: I don't know if it matters, but I use Ubuntu 14.04 and chromium browser
Upvotes: 2
Views: 1170
Reputation: 926
Use to set session maxtime:
use following code in your confiuguration file:
// each client should remember their session id for EXACTLY 10 hour
ini_set('session.gc_maxlifetime', 36000);
session_set_cookie_params(36000);
Write this lines before session_start();
Or you can set it in your php.ini file too.
Upvotes: 1