Files
spa-api/laravel/session/file.php

28 lines
600 B
PHP
Raw Normal View History

2011-08-18 19:56:29 -05:00
<?php namespace Laravel\Session;
2011-06-08 23:45:08 -05:00
2011-08-19 20:12:39 -05:00
class File extends Driver implements Sweeper {
2011-06-08 23:45:08 -05:00
2011-08-19 20:12:39 -05:00
protected function load($id)
2011-06-08 23:45:08 -05:00
{
2011-08-08 10:30:19 -05:00
if (file_exists($path = SESSION_PATH.$id)) return unserialize(file_get_contents($path));
2011-06-08 23:45:08 -05:00
}
2011-08-19 20:12:39 -05:00
protected function save()
2011-06-08 23:45:08 -05:00
{
2011-08-19 20:12:39 -05:00
file_put_contents(SESSION_PATH.$this->session['id'], serialize($this->session), LOCK_EX);
2011-06-08 23:45:08 -05:00
}
2011-08-19 20:12:39 -05:00
protected function delete()
2011-06-08 23:45:08 -05:00
{
2011-08-19 20:12:39 -05:00
@unlink(SESSION_PATH.$this->session['id']);
2011-06-08 23:45:08 -05:00
}
public function sweep($expiration)
{
2011-07-26 22:11:16 -05:00
foreach (glob(SESSION_PATH.'*') as $file)
2011-06-08 23:45:08 -05:00
{
2011-08-08 10:30:19 -05:00
if (filetype($file) == 'file' and filemtime($file) < $expiration) @unlink($file);
2011-06-08 23:45:08 -05:00
}
}
}