1 | <?php |
||
13 | class FlipSession extends Singleton |
||
14 | { |
||
15 | /** |
||
16 | * Does the variable exist in the session |
||
17 | * |
||
18 | * @SuppressWarnings(PHPMD.Superglobals) |
||
19 | */ |
||
20 | static function doesVarExist($name) |
||
24 | |||
25 | /** |
||
26 | * Get a variable from the session |
||
27 | * |
||
28 | * @SuppressWarnings(PHPMD.Superglobals) |
||
29 | */ |
||
30 | static function getVar($name, $default = false) |
||
41 | |||
42 | /** |
||
43 | * Set a variable in the session |
||
44 | * |
||
45 | * @SuppressWarnings(PHPMD.Superglobals) |
||
46 | */ |
||
47 | static function setVar($name, $value) |
||
51 | |||
52 | /** |
||
53 | * Is a user currently logged in? |
||
54 | * |
||
55 | * @SuppressWarnings(PHPMD.Superglobals) |
||
56 | */ |
||
57 | static function isLoggedIn() |
||
73 | |||
74 | /** |
||
75 | * Get the currently logged in user |
||
76 | * |
||
77 | * @SuppressWarnings(PHPMD.Superglobals) |
||
78 | */ |
||
79 | static function getUser() |
||
100 | |||
101 | /** |
||
102 | * Set the currently logged in user |
||
103 | * |
||
104 | * @SuppressWarnings(PHPMD.Superglobals) |
||
105 | */ |
||
106 | static function setUser($user) |
||
110 | |||
111 | /** |
||
112 | * Obtain the current users email address |
||
113 | * |
||
114 | * @SuppressWarnings(PHPMD.Superglobals) |
||
115 | */ |
||
116 | static function getUserEmail() |
||
134 | |||
135 | /** |
||
136 | * This will end your session |
||
137 | * |
||
138 | * @SuppressWarnings(PHPMD.Superglobals) |
||
139 | */ |
||
140 | static function end() |
||
148 | |||
149 | static function unserializePhpSession($sessionData) |
||
150 | { |
||
151 | $res = array(); |
||
152 | $offset = 0; |
||
153 | $length = strlen($sessionData); |
||
154 | while($offset < $length) |
||
155 | { |
||
156 | $pos = strpos($sessionData, "|", $offset); |
||
157 | $len = $pos - $offset; |
||
158 | $name = substr($sessionData, $offset, $len); |
||
159 | if($name === false) break; |
||
160 | $offset += $len + 1; |
||
161 | $data = @unserialize(substr($sessionData, $offset)); |
||
162 | $res[$name] = $data; |
||
163 | $offset += strlen(serialize($data)); |
||
164 | } |
||
165 | return $res; |
||
166 | } |
||
167 | |||
168 | static function getAllSessions() |
||
198 | |||
199 | static function getSessionById($sid) |
||
204 | |||
205 | static function deleteSessionById($sid) |
||
209 | } |
||
210 | /* vim: set tabstop=4 shiftwidth=4 expandtab: */ |
||
211 |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.