]>
git.datanom.net - qtadmin.git/blob - lib/session_handler.inc.php
0f02690e277f760b402485893cdda836523fa2b9
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 $result = file_put_contents("$this->savePath/qt_sess_$id", $data);
24 chmod("$this->savePath/qt_sess_$id", 0600);
26 return ($result === false) ?
false : true;
29 function destroy($id) {
30 $file = "$this->savePath/qt_sess_$id";
31 if (file_exists($file)) {
38 function gc($maxlifetime) {
39 foreach (glob("$this->savePath/qt_sess_*") as $file) {
40 if (filemtime($file) +
$maxlifetime < time() && file_exists($file)) {
49 $handler = new FileSessionHandler();
50 session_set_save_handler(
51 array($handler, 'open'),
52 array($handler, 'close'),
53 array($handler, 'read'),
54 array($handler, 'write'),
55 array($handler, 'destroy'),
59 // the following prevents unexpected effects when using objects as save handlers
60 register_shutdown_function('session_write_close');
This page took 0.071394 seconds and 4 git commands to generate.