Skip to content

Instantly share code, notes, and snippets.

@cronoh
Created December 10, 2016 17:43
Show Gist options
  • Save cronoh/267ff2f2e019cf0ed258ab909c8bcc49 to your computer and use it in GitHub Desktop.
Save cronoh/267ff2f2e019cf0ed258ab909c8bcc49 to your computer and use it in GitHub Desktop.
Laravel 5.x Native Session Handler
<?php
namespace App\Extensions;
use SessionHandlerInterface;
class NativeSessionHandler implements SessionHandlerInterface
{
public function open($savePath, $sessionName)
{
}
public function close()
{
}
public function read($sessionId)
{
return serialize(isset($_SESSION) ? $_SESSION : null);
}
public function write($sessionId, $data)
{
$_SESSION = unserialize($data);
}
public function destroy($sessionId)
{
}
public function gc($lifetime)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment