ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
class.ilSessionDBHandler.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 1998-2009 ILIAS open source, Extended GPL, see docs/LICENSE */
4
5include_once("./Services/Authentication/classes/class.ilSession.php");
6
15{
16 /*
17 * register callback functions
18 * session.save_handler must be 'user' or safe mode off to succeed
19 */
20 public function setSaveHandler()
21 {
22 // register save handler functions
23 if (ini_get("session.save_handler") == "user")
24 {
25 session_set_save_handler(
26 array($this, "open"),
27 array($this, "close"),
28 array($this, "read"),
29 array($this, "write"),
30 array($this, "destroy"),
31 array($this, "gc"));
32
33 return true;
34 }
35
36 return false;
37 }
38
39 /*
40 * open session, normally a db connection would be opened here, but
41 * we use the standard ilias db connection, so nothing must be done here
42 *
43 * @param string $save_pathDSN information about how to access the database, format:
44 * dbtype(dbsyntax)://username:password@protocol+hostspec/database
45 * eg. mysql://phpsessmgr:topsecret@db.example.com/sessiondb
46 * @param string $name session name [PHPSESSID]
47 */
48 public function open($save_path, $name)
49 {
50 return true;
51 }
52
58 public function close()
59 {
60 return true;
61 }
62
63 /*
64 * Reads data of the session identified by $session_id and returns it as a
65 * serialised string. If there is no session with this ID an empty string is
66 * returned
67 *
68 * @param integer $session_id session id
69 */
70 public function read($session_id)
71 {
72 return ilSession::_getData($session_id);
73 }
74
81 public function write($session_id, $data)
82 {
83 $cwd = getcwd();
84 chdir(IL_INITIAL_WD);
85 include_once("./Services/Authentication/classes/class.ilSession.php");
86 $r = ilSession::_writeData($session_id, $data);
87 // see bug http://www.ilias.de/mantis/view.php?id=18000
88 //chdir($cwd);
89 return $r;
90 }
91
97 public function destroy($session_id)
98 {
99 return ilSession::_destroy($session_id);
100 }
101
107 public function gc($gc_maxlifetime)
108 {
110 }
111}
112
113// needs to be done to assure that $ilDB exists,
114// when db_session_write is called
115register_shutdown_function("session_write_close");
116
117?>
Database Session Handling.
gc($gc_maxlifetime)
removes sessions that weren't updated for more than gc_maxlifetime seconds
destroy($session_id)
destroy session
write($session_id, $data)
Writes serialized session data to the database.
static _writeData($a_session_id, $a_data)
Write session data.
static _destroyExpiredSessions()
Destroy expired sessions.
static _destroy($a_session_id, $a_closing_context=null, $a_expired_at=null)
Destroy session.
static _getData($a_session_id)
Get session data from table.
$data
$r
Definition: example_031.php:79
const IL_INITIAL_WD
Definition: error.php:5