i want to set session time out limit by 3 min ,
i have used this in the page
ini_set("session.gc_maxlifetime", "50"); not working
Solution for this
if (isset($_SESSION['LAST_ACTIVITY']) && (time() - $_SESSION['LAST_ACTIVITY'] > 1800)) {
// last request was more than 30 minutes ago session_destroy();
// destroy session data in storage session_unset();
// unset $_SESSION variable for the runtime
}
$_SESSION['LAST_ACTIVITY'] = time(); // update last activity time stamp
The session will live as long as the file is left on the server’s file system. They are cleaned out by a garbage collector. The garbage collector is run approximately every hundred page loads on the server (this is rather random, the “every hundred” page loads is just an average).
Also, the age of the session is inactive age, not total age. The timer will be reset for that session every time the user does a request.