ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
inc.db_session_handler.php
Go to the documentation of this file.
1 <?php
11 /*
12  +-----------------------------------------------------------------------------+
13  | ILIAS open source |
14  +-----------------------------------------------------------------------------+
15  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
16  | |
17  | This program is free software; you can redistribute it and/or |
18  | modify it under the terms of the GNU General Public License |
19  | as published by the Free Software Foundation; either version 2 |
20  | of the License, or (at your option) any later version. |
21  | |
22  | This program is distributed in the hope that it will be useful, |
23  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
24  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
25  | GNU General Public License for more details. |
26  | |
27  | You should have received a copy of the GNU General Public License |
28  | along with this program; if not, write to the Free Software |
29  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
30  +-----------------------------------------------------------------------------+
31 */
32 
33 include_once("./Services/Authentication/classes/class.ilSession.php");
34 
35 /*
36 * open session, normally a db connection would be opened here, but
37 * we use the standard ilias db connection, so nothing must be done here
38 *
39 * @param string $save_pathDSN information about how to access the database, format:
40 * dbtype(dbsyntax)://username:password@protocol+hostspec/database
41 * eg. mysql://phpsessmgr:topsecret@db.example.com/sessiondb
42 * @param string $name session name [PHPSESSID]
43 */
44 function db_session_open($save_path, $name)
45 {
46  return true;
47 }
48 
54 function db_session_close()
55 {
56  return true;
57 }
58 
59 /*
60 * Reads data of the session identified by $session_id and returns it as a
61 * serialised string. If there is no session with this ID an empty string is
62 * returned
63 *
64 * @param integer $session_id session id
65 */
66 function db_session_read($session_id)
67 {
68  return ilSession::_getData($session_id);
69 }
70 
77 function db_session_write($session_id, $data)
78 {
79  return ilSession::_writeData($session_id, $data);
80 }
81 
87 function db_session_destroy($session_id)
88 {
89  return ilSession::_destroy($session_id);
90 }
91 
92 
98 function db_session_gc($gc_maxlifetime)
99 {
101 }
102 
103 
104 /*
105 * register callback functions
106 * session.save_handler must be 'user' or safe mode off to succeed
107 */
109 {
110  // register save handler functions
111  if (ini_get("session.save_handler") == "user")
112  {
113  session_set_save_handler(
114  "db_session_open",
115  "db_session_close",
116  "db_session_read",
117  "db_session_write",
118  "db_session_destroy",
119  "db_session_gc");
120 
121  return true;
122  }
123 
124  return false;
125 }
126 
127 function duplicate_session($a_session_id)
128 {
129  return ilSession::_duplicate($a_session_id);
130 }
131 
132 // needs to be done to assure that $ilDB exists,
133 // when db_session_write is called
134 register_shutdown_function("session_write_close");
135 
136 ?>