]>
git.datanom.net - qtadmin.git/blob - lib/session_handler.inc.php
2 class FileSessionHandler
{
5 function open($savePath, $sessionName) {
6 $this->savePath
= $savePath;
7 if (!is_dir($this->savePath
)) {
8 mkdir($this->savePath
, 0777);
19 return (string)@file_get_contents
("$this->savePath/qt_sess_$id");
22 function write($id, $data) {
23 return file_put_contents("$this->savePath/qt_sess_$id", $data) === false ?
false : true;
26 function destroy($id) {
27 $file = "$this->savePath/qt_sess_$id";
28 if (file_exists($file)) {
35 function gc($maxlifetime) {
36 foreach (glob("$this->savePath/qt_sess_*") as $file) {
37 if (filemtime($file) +
$maxlifetime < time() && file_exists($file)) {
46 $handler = new FileSessionHandler();
47 session_set_save_handler(
48 array($handler, 'open'),
49 array($handler, 'close'),
50 array($handler, 'read'),
51 array($handler, 'write'),
52 array($handler, 'destroy'),
56 // the following prevents unexpected effects when using objects as save handlers
57 register_shutdown_function('session_write_close');
This page took 0.129044 seconds and 6 git commands to generate.