61154c79e042654eda35423f58a014941acc628c
1 <?php
2 /*
3 This code is part of GOsa (https://oss.gonicus.de/labs/gosa/)
4 Copyright (C) 2007 Fabian Hickert
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
22 class session {
24 public static function get_session_size()
25 {
27 }
29 public static function get_element_size()
30 {
32 }
34 public static function is_set($name)
35 {
36 session::log("Checked if element '".$name."' exists. Returned (".isset($_SESSION[$name]).")");
37 return(isset($_SESSION[$name]));
38 }
40 public static function set($name,$value)
41 {
42 session::log("Set '".$name."' to '".gettype($value)."'.");
43 $_SESSION[$name] = $value;
44 }
46 public static function &get($name)
47 {
48 $ret = FALSE;
49 if(session::is_set($name)){
50 $ret = $_SESSION[$name];
51 session::log("Returned '".gettype($ret)."' for '".$name."'.");
52 }else{
53 session::log("Returned FALSE for '".$name."'. Element wasn't set.");
54 }
55 return($ret);
56 }
58 public static function delete($name)
59 {
60 if(session::is_set($name)){
61 unset($_SESSION[$name]);
62 session::log("Removed element '".$name."'.");
63 }else{
64 session::log("Tried to remove element '".$name."'. Element wasn't set.");
65 }
66 }
68 public static function un_set($name)
69 {
70 return(session::delete($name));
71 }
73 public static function start()
74 {
75 /* Set cookie lifetime to one day (The parameter is in seconds ) */
76 session_set_cookie_params(24*60*60);
78 /* Set cache limter to one day (parameter is minute !!)*/
79 session_cache_expire(60*24); // default is 180
81 /* Set session max lifetime, to prevent the garbage collector to delete session before timeout.
82 !! The garbage collector is a cron job on debian systems, the cronjob will fetch the timeout from
83 the php.ini, so if you use debian, you must hardcode session.gc_maxlifetime in your php.ini */
84 ini_set("session.gc_maxlifetime",24*60*60);
85 session_start();
86 session::log("Session startet");
87 }
89 public static function destroy()
90 {
91 session_destroy();
92 }
94 public static function set_lifetime($seconds = -1)
95 {
96 echo "Not implemented yet";
97 }
99 private static function log($str)
100 {
101 # echo $str."<br>";
102 }
104 public static function &get_all()
105 {
106 session::log("Returned complete session.");
107 return($_SESSION);
108 }
109 }
111 ?>