This blog contains information regarding PHP,HTML, CSS, AJAX, JQUERY AND EXTJS.
Friday, May 7, 2010
How to increase your session time out PHP
/*********************** Increase the session time out *****************/
$values = $_SESSION;
// keep session config
$trans = ini_get( 'session.use_trans_sid' );
if( $trans ) {
ini_set( 'session.use_trans_sid', 0 );
}
$cookie = session_get_cookie_params();
// create new session id
$id = 0;
while (strlen($id) < 32) {
$id .= mt_rand(0, mt_getrandmax());
}
$id = md5( uniqid($id, true));
// kill session
session_destroy();
$cookie['lifetime'] = 7*60; // minutes * 60
// restore config
ini_set( 'session.use_trans_sid', $trans );
session_set_cookie_params( $cookie['lifetime'], $cookie['path'], $cookie['domain'], $cookie['secure'] );
session_cache_expire($cookie['lifetime'] / 60);
ini_set('session.gc_maxlifetime', $cookie['lifetime']);
// restart session with new id
session_id( $id );
session_start();
$_SESSION = $values;
/*********************************** End *******************************/
?>
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment