forked from sdc/xerte_2.0
-
Notifications
You must be signed in to change notification settings - Fork 0
/
session_handler.php
87 lines (42 loc) · 1.39 KB
/
session_handler.php
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
85
86
87
<?PHP
class toolkits_session_handler{
var $database_connect;
function toolkits_session_handler(){
}
function xerte_session_open(){
global $xerte_toolkits_site;
$this->database_connect = mysql_connect($xerte_toolkits_site->database_host, $xerte_toolkits_site->database_username, $xerte_toolkits_site->database_password);
mysql_select_db($xerte_toolkits_site->database_name);
return TRUE;
}
function xerte_session_close(){
mysql_close();
}
function xerte_session_read($id){
global $xerte_toolkits_site;
$response = mysql_query("select data from user_sessions where session_id = '$id'");
$value = mysql_fetch_object($response);
if(isset($value->data)){
return $value->data;
}else{
return false;
}
}
function xerte_session_write($id,$data){
global $xerte_toolkits_site;
$access = time();
mysql_query("replace into user_sessions values('$id','$access','$data')");
}
function xerte_session_destroy($id){
global $xerte_toolkits_site;
mysql_query("delete from user_sessions where session_id = '$id'");
}
function xerte_session_clean($max){
global $xerte_toolkits_site;
$old = time() - $max;
$old = mysql_real_escape_string($old);
$sql = "delete from user_sessions WHERE access < '$old'";
mysql_query($sql);
}
}
?>