Code

Fixed get_all too
[gosa.git] / gosa-core / include / class_session.inc
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         {
31         
32         }
34         public static function is_set($name)
35         {
36                 return(isset($_SESSION[$name]));
37         }
39         public static function set($name,$value)
40         {
41                 $_SESSION[$name] = $value;
42         }
44         public static function &get($name)
45         {
46                 $ret = &$_SESSION[$name];
47                 return($ret);
48         }
50         public static function delete($name)
51         {
52                 if(session::is_set($name)){
53                         unset($_SESSION[$name]);
54                 }
55         }
57         public static function un_set($name)
58         {
59                 return(session::delete($name));
60         }
62         public static function start()
63         {
64                 /* Set cookie lifetime to one day (The parameter is in seconds ) */
65                 session_set_cookie_params(24*60*60);
67                 /* Set cache limter to one day (parameter is minute !!)*/
68                 session_cache_expire(60*24);  // default is 180
70                 /* Set session max lifetime, to prevent the garbage collector to delete session before timeout.
71                    !! The garbage collector is a cron job on debian systems, the cronjob will fetch the timeout from
72                    the php.ini, so if you use debian, you must hardcode session.gc_maxlifetime in your php.ini */
73                 ini_set("session.gc_maxlifetime",24*60*60);
74                 session_start();
75         }
77         public static function destroy()
78         {
79                 session_destroy();
80         }
82         public static function set_lifetime($seconds = -1)
83         {
84                 echo "Not implemented yet";
85         }
87         public static function &get_all()
88         {
89                 $ret = &$_SESSION;
90                 return($ret);
91         }
92 }
94 ?>