Skip to content

Instantly share code, notes, and snippets.

@dammyammy
Created March 12, 2015 20:55
Show Gist options
  • Select an option

  • Save dammyammy/14fd8a69cc6df945819f to your computer and use it in GitHub Desktop.

Select an option

Save dammyammy/14fd8a69cc6df945819f to your computer and use it in GitHub Desktop.
Usage Of Session Handler Class
$session = new SecureSessionHandler('cheese');
ini_set('session.save_handler', 'files');
session_set_save_handler($session, true);
session_save_path(__DIR__ . '/sessions');
$session->start();
if ( ! $session->isValid(5)) {
$session->destroy();
}
$session->put('hello.world', 'bonjour');
echo $session->get('hello.world'); // bonjour
@silverweed
Copy link
Copy Markdown

How do you reuse the $session object across pages?
i.e. what if I create a new session in a login.php page, then I redirect to secure.php and want to check whether the session is still valid?

@dammyammy
Copy link
Copy Markdown
Author

call $session->isValid();

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment