Update v1.0.6

This commit is contained in:
Bhanu Slathia
2016-02-16 23:24:52 +05:30
parent c710c20b9e
commit b1f62846ab
7662 changed files with 1361647 additions and 0 deletions

View File

@@ -0,0 +1,98 @@
<?php namespace Illuminate\Session;
use SessionHandlerInterface;
use Symfony\Component\Finder\Finder;
use Illuminate\Filesystem\Filesystem;
class FileSessionHandler implements SessionHandlerInterface {
/**
* The filesystem instance.
*
* @var \Illuminate\Filesystem\Filesystem
*/
protected $files;
/**
* The path where sessions should be stored.
*
* @var string
*/
protected $path;
/**
* Create a new file driven handler instance.
*
* @param \Illuminate\Filesystem\Filesystem $files
* @param string $path
* @return void
*/
public function __construct(Filesystem $files, $path)
{
$this->path = $path;
$this->files = $files;
}
/**
* {@inheritDoc}
*/
public function open($savePath, $sessionName)
{
return true;
}
/**
* {@inheritDoc}
*/
public function close()
{
return true;
}
/**
* {@inheritDoc}
*/
public function read($sessionId)
{
if ($this->files->exists($path = $this->path.'/'.$sessionId))
{
return $this->files->get($path);
}
return '';
}
/**
* {@inheritDoc}
*/
public function write($sessionId, $data)
{
$this->files->put($this->path.'/'.$sessionId, $data, true);
}
/**
* {@inheritDoc}
*/
public function destroy($sessionId)
{
$this->files->delete($this->path.'/'.$sessionId);
}
/**
* {@inheritDoc}
*/
public function gc($lifetime)
{
$files = Finder::create()
->in($this->path)
->files()
->ignoreDotFiles(true)
->date('<= now - '.$lifetime.' seconds');
foreach ($files as $file)
{
$this->files->delete($file->getRealPath());
}
}
}