Skip to content

Instantly share code, notes, and snippets.

@bshaffer
Created October 2, 2019 23:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bshaffer/31d6e1c9efc369a27fa5bf7be61e9f4c to your computer and use it in GitHub Desktop.
Save bshaffer/31d6e1c9efc369a27fa5bf7be61e9f4c to your computer and use it in GitHub Desktop.
<?php
class NullSessionHandler implements SessionHandlerInterface
{
public function open($savePath, $sessionName)
{
return true;
}
public function close()
{
return true;
}
public function read($sessionId)
{
return '';
}
public function write($sessionId, $data)
{
return true;
}
public function destroy($sessionId)
{
return true;
}
public function gc($lifetime)
{
return 1;
}
}
$handler = new NullSessionHandler();
session_set_save_handler($handler, true);
session_start();
$result = session_gc();
var_dump($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment