Code

Added session ID regeneration
[gosa.git] / gosa-core / include / class_session.inc
1 <?php
2 /*
3  * This code is part of GOsa (http://www.gosa-project.org)
4  * Copyright (C) 2003-2008 GONICUS GmbH
5  *
6  * ID: $$Id$$
7  *
8  * This program is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2 of the License, or
11  * (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, write to the Free Software
20  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
21  */
23 class session {
25         public static function get_session_size()
26         {
28         }
30         public static function get_element_size()
31         {
32         
33         }
35         public static function is_set($name)
36         {
37                 return(isset($_SESSION[$name]));
38         }
40         public static function set($name,$value)
41         {
42                 $_SESSION[$name] = $value;
43         }
45         public static function &get($name)
46         {
47                 $ret = &$_SESSION[$name];
48                 return($ret);
49         }
51         public static function delete($name)
52         {
53                 if(session::is_set($name)){
54                         unset($_SESSION[$name]);
55                 }
56         }
58         public static function un_set($name)
59         {
60                 return(session::delete($name));
61         }
63         public static function start()
64         {
65                 /* Set cookie lifetime to one day (The parameter is in seconds ) */
66                 session_set_cookie_params(24*60*60);
68                 /* Set cache limter to one day (parameter is minute !!)*/
69                 session_cache_expire(60*24);  // default is 180
71                 /* Set session max lifetime, to prevent the garbage collector to delete session before timeout.
72                    !! The garbage collector is a cron job on debian systems, the cronjob will fetch the timeout from
73                    the php.ini, so if you use debian, you must hardcode session.gc_maxlifetime in your php.ini */
74                 ini_set("session.gc_maxlifetime",24*60*60);
75                 session_start();
77     /* Regenerate ID to increase security */
78     if (!isset($_SESSION['started'])){
79       session_regenerate_id();
80       $_SESSION['started'] = true;
81     }
82         }
84         public static function destroy()
85         {
86                 session_destroy();
87         }
89         public static function set_lifetime($seconds = -1)
90         {
91                 echo "Not implemented yet";
92         }
94         public static function &get_all()
95         {
96                 $ret = &$_SESSION;
97                 return($ret);
98         }
99 }
101 ?>