Skip to content

Instantly share code, notes, and snippets.

@weltling
Last active January 21, 2016 16:31
Show Gist options
  • Save weltling/2a78b676b956f72373c4 to your computer and use it in GitHub Desktop.
Save weltling/2a78b676b956f72373c4 to your computer and use it in GitHub Desktop.
<?php
ob_start();
session_save_path("/tmp");
$sid = md5(uniqid());
class CustomReadHandler extends SessionHandler {
public function read($session_id)
{
return strval(file_get_contents(session_save_path() . '/sess_' . $session_id));
}
}
session_set_save_handler(new CustomReadHandler(), true);
$handler = new CustomReadHandler();
session_name('sessionname');
session_id($sid);
session_start();
//$this->assertEmpty($_SESSION);
var_dump(empty($_SESSION));
$_SESSION['sessiondata'] = 'foo';
var_dump($_SESSION);
session_write_close();
var_dump($handler->read($sid));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment