|
@@ -47,7 +47,7 @@ class CacheSession extends Root implements SessionHandlerInterface |
|
@@ -47,7 +47,7 @@ class CacheSession extends Root implements SessionHandlerInterface |
47
|
/**
|
47
|
/**
|
48
|
* 初始化
|
48
|
* 初始化
|
49
|
*/
|
49
|
*/
|
50
|
- public function __construct()
|
50
|
+ public function __construct($sessionName = null, $domain = null)
|
51
|
{
|
51
|
{
|
52
|
session_set_save_handler(
|
52
|
session_set_save_handler(
|
53
|
array(&$this, "open"),
|
53
|
array(&$this, "open"),
|
|
@@ -60,8 +60,14 @@ class CacheSession extends Root implements SessionHandlerInterface |
|
@@ -60,8 +60,14 @@ class CacheSession extends Root implements SessionHandlerInterface |
60
|
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
60
|
if (version_compare(phpversion(), '5.4.0', '>=')) {
|
61
|
register_shutdown_function('session_write_close');
|
61
|
register_shutdown_function('session_write_close');
|
62
|
}
|
62
|
}
|
|
|
63
|
+ if ($sessionName != null && is_string($sessionName) && strlen($sessionName) > 1) {
|
|
|
64
|
+ ini_set("session.name", $sessionName);
|
|
|
65
|
+ }
|
63
|
ini_set("session.use_cookies", 1);
|
66
|
ini_set("session.use_cookies", 1);
|
64
|
- ini_set("session.cookie_domain", ".yohobuy.com");
|
67
|
+ ini_set('use_only_cookies', 0);
|
|
|
68
|
+ if ($domain != null) {
|
|
|
69
|
+ ini_set("session.cookie_domain", '.' . $domain);
|
|
|
70
|
+ }
|
65
|
ini_set('session.cookie_path', '/');
|
71
|
ini_set('session.cookie_path', '/');
|
66
|
ini_set('session.gc_maxlifetime', $this->gcMaxLifeTime);
|
72
|
ini_set('session.gc_maxlifetime', $this->gcMaxLifeTime);
|
67
|
}
|
73
|
}
|
|
@@ -145,7 +151,6 @@ class CacheSession extends Root implements SessionHandlerInterface |
|
@@ -145,7 +151,6 @@ class CacheSession extends Root implements SessionHandlerInterface |
145
|
public function write($sessionID, $sessionData)
|
151
|
public function write($sessionID, $sessionData)
|
146
|
{
|
152
|
{
|
147
|
$return = $this->cache()->set($this->sessionPrefix . $sessionID, $sessionData, $this->gcMaxLifeTime);
|
153
|
$return = $this->cache()->set($this->sessionPrefix . $sessionID, $sessionData, $this->gcMaxLifeTime);
|
148
|
- var_dump($return);exit;
|
|
|
149
|
return $return;
|
154
|
return $return;
|
150
|
}
|
155
|
}
|
151
|
|
156
|
|