source: branches/feature-module-paygent/data/include/session.inc @ 8

Revision 8, 1.9 KB checked in by root, 14 years ago (diff)

new import

Line 
1<?php
2
3$SESSION_HANDLER_PHP_PATH = realpath( dirname( __FILE__) );
4require_once($SESSION_HANDLER_PHP_PATH ."/../class/SC_Query.php" );
5require_once($SESSION_HANDLER_PHP_PATH ."/../lib/glib.php" );
6
7// ¥»¥Ã¥·¥ç¥ó¤ÎÍ­¸ú´ü¸Â(ÉÃ)
8define("MAX_LIFETIME", 7200);
9
10function sfSessOpen($save_path, $session_name)
11{
12  return true;
13}
14
15function sfSessClose()
16{
17  return true;
18}
19
20// ¥»¥Ã¥·¥ç¥óÆɤ߹þ¤ß
21function sfSessRead($id)
22{
23    $objQuery = new SC_Query();
24    $arrRet = $objQuery->select("sess_data", "dtb_session", "sess_id = ?", array($id));
25    return($arrRet[0]['sess_data']);
26}
27
28// ¥»¥Ã¥·¥ç¥ó½ñ¹þ¤ß
29function sfSessWrite($id, $sess_data)
30{
31    $objQuery = new SC_Query();
32    $count = $objQuery->count("dtb_session", "sess_id = ?", array($id));
33    $sqlval = array();
34    if($count > 0) {
35        // ¥ì¥³¡¼¥É¹¹¿·
36        $sqlval['sess_data'] = $sess_data;
37        $sqlval['update_date'] = 'Now()';
38        $objQuery->update("dtb_session", $sqlval, "sess_id = ?", array($id));
39    } else {
40        // ¥»¥Ã¥·¥ç¥ó¥Ç¡¼¥¿¤¬¤¢¤ë¾ì¹ç¤Ï¡¢¥ì¥³¡¼¥ÉºîÀ®
41        if(strlen($sess_data) > 0) {
42            $sqlval['sess_id'] = $id;
43            $sqlval['sess_data'] = $sess_data;
44            $sqlval['update_date'] = 'Now()';       
45            $sqlval['create_date'] = 'Now()';       
46            $objQuery->insert("dtb_session", $sqlval);
47        }
48    }
49    return true;
50}
51
52// ¥»¥Ã¥·¥ç¥óÇË´þ
53function sfSessDestroy($id)
54{
55    $objQuery = new SC_Query();
56    $objQuery->delete("dtb_session", "sess_id = ?", array($id));
57    return true;
58}
59
60function sfSessGc($maxlifetime)
61{
62    // ¢¨$maxlifetime¤Ï¡¢ÍøÍѤ·¤Ê¤¤¡£
63    // MAX_LIFETIME°Ê¾å¹¹¿·¤µ¤ì¤Æ¤¤¤Ê¤¤¥»¥Ã¥·¥ç¥ó¤òºï½ü¤¹¤ë¡£
64    $objQuery = new SC_Query();
65    $where = "update_date < current_timestamp + '-". MAX_LIFETIME . " secs'";
66    $objQuery->delete("dtb_session", $where);
67    return true;
68}
69
70if(sfTabaleExists("dtb_session")) {
71    session_set_save_handler("sfSessOpen", "sfSessClose", "sfSessRead", "sfSessWrite", "sfSessDestroy", "sfSessGc");
72}
73?>
Note: See TracBrowser for help on using the repository browser.