1 |
bareface |
1.1 |
<?php |
2 |
|
|
|
3 |
|
|
class YakkaSessionHandler { |
4 |
|
|
var $ticket; |
5 |
|
|
|
6 |
|
|
function YakkaSessionHandler($sessionKey) { |
7 |
|
|
if ($sessionKey != null) |
8 |
|
|
session_id($sessionKey); |
9 |
|
|
else |
10 |
|
|
session_id(md5(uniqid(rand(),1))); |
11 |
|
|
|
12 |
|
|
session_start(); |
13 |
|
|
|
14 |
|
|
global $HTTP_SESSION_VARS; |
15 |
|
|
|
16 |
|
|
if ($HTTP_SESSION_VARS["ticket"]) { |
17 |
|
|
$this->ticket = $HTTP_SESSION_VARS["ticket"]; |
18 |
|
|
$this->ticket->expired = false; |
19 |
|
|
$now = time(); |
20 |
|
|
if ($this->ticket->sessionTime && ($now - $this->ticket->sessionTime) > 1800) { |
21 |
|
|
//$this->ClearSession(); |
22 |
|
|
$this->ticket->sessionTime = $now; |
23 |
|
|
} else |
24 |
|
|
$this->ticket->sessionTime = $now; |
25 |
|
|
} else { |
26 |
|
|
$this->ticket = null; |
27 |
|
|
$this->ticket->expired = false; |
28 |
|
|
if ($sessionKey != null) |
29 |
|
|
$this->ClearSession(); |
30 |
|
|
} |
31 |
|
|
|
32 |
|
|
$this->ticket->id = session_id(); |
33 |
|
|
} |
34 |
|
|
|
35 |
|
|
function clearSession() { |
36 |
|
|
$this->ticket = null; |
37 |
|
|
$this->ticket->expired = true; |
38 |
|
|
$this->ticket->sessionTime = time(); |
39 |
|
|
session_id(md5(uniqid(rand(),1))); |
40 |
|
|
} |
41 |
|
|
|
42 |
|
|
function &loadSession() { |
43 |
|
|
return $this->ticket; |
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
function saveSession() { |
47 |
|
|
global $HTTP_SESSION_VARS; |
48 |
|
|
$HTTP_SESSION_VARS["ticket"] = &$this->ticket; |
49 |
|
|
} |
50 |
|
|
} |
51 |
|
|
|
52 |
|
|
?> |