Skip to content

Instantly share code, notes, and snippets.

@abidibo
Created November 7, 2011 15:59
Show Gist options
  • Save abidibo/1345352 to your computer and use it in GitHub Desktop.
Save abidibo/1345352 to your computer and use it in GitHub Desktop.
Recreate a php session
<?php
define('SESSION_TIMEOUT', '1800'); // 30 minutes
session_name('fuckIE');
session_start();
// ...bla bla
if (isset($_SESSION['last_activity']) && (time() - $_SESSION['last_activity'] > SESSION_TIMEOUT)) {
// last request was more than timeout seconds ago
session_regenerate_id(true);
session_destroy();
unset($_SESSION);
session_start();
}
$_SESSION['last_activity'] = time();
// ...bla bla
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment