blob: 34f8ced73926a1682d9f6fac1fff79fa9ec6beb0 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<?php
/**
* Simple class for accessing session data
* @package Core
*/
class Session{
/**
* Flag to check if the session was already intialized
* @var boolean
* @access private
* @static
*/
private static $initialized=false;
/**
* Makes sure the session is initialized
*
* @return void
* @access private
* @static
*/
private static function check(){
if(!Session::$initialized){
session_start();
Session::$initialized=true;
}
}
/**
* Gets a session variable
*
* @param string $key Variable name
* @param mixed $default Default value
* @return mixed Session value
* @access public
* @static
*/
public static function get($key, $default = null) {
Session::check();
return Misc::arr($_SESSION,$key,$default);
}
/**
* Sets a session variable
*
* @param string $key Variable name
* @param mixed $val Variable value
* @return void
* @access public
* @static
*/
public static function set($key, $val) {
Session::check();
$_SESSION[$key]=$val;
}
/**
* Removes a session variable
*
* @param string $key Variable name
* @return void
* @access public
* @static
*/
public static function remove($key) {
Session::check();
$var = $_SESSION[$key];
unset($_SESSION[$key], $var);
}
/**
* Resets the session
*
* @return void
* @access public
* @static
*/
public static function reset() {
Session::check();
$_SESSION=array();
}
}
|