Session timeout setting is necessary For high-security sites . Php default session timeout time is 20 minutes.
There is 2 functions for change the session timeout.
1. Sets the timeout of a current session and
2. Verifies whether the session is still valid given the specified timeout variable set in above function .
function check_login() {
@session_start();
$expiration_time = intval($_SESSION['session_expiration']);
//if session is still valid
if ($time() < $expiration_time) {
validate_session('600'); // -> make it valid for another 600 secs
return true;
}
else {
unset($_SESSION['session_expiration']);
return false;
}
}
function validate_session($timeout) {
@session_start();
$_SESSION['session_expiration'] = time() + $timeout;
}
There is 2 functions for change the session timeout.
1. Sets the timeout of a current session and
2. Verifies whether the session is still valid given the specified timeout variable set in above function .
function check_login() {
@session_start();
$expiration_time = intval($_SESSION['session_expiration']);
//if session is still valid
if ($time() < $expiration_time) {
validate_session('600'); // -> make it valid for another 600 secs
return true;
}
else {
unset($_SESSION['session_expiration']);
return false;
}
}
function validate_session($timeout) {
@session_start();
$_SESSION['session_expiration'] = time() + $timeout;
}
0 comments:
Post a Comment