Skip to content

Commit 238905a

Browse files
committed
Don't try to use shared session for locahost
1 parent e7d4c80 commit 238905a

File tree

2 files changed

+10
-7
lines changed

2 files changed

+10
-7
lines changed

system/session.php

+9-6
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,10 @@ public static function getInstance() {
3030

3131
if ($inst === null) {
3232
$driver = \Vvveb\config(APP . '.session.driver', 'php');
33-
$inst = new Session($driver);
33+
34+
if ($driver) {
35+
$inst = new Session($driver);
36+
}
3437
}
3538

3639
return $inst;
@@ -50,22 +53,22 @@ public function __construct($driver, $expire = 3600) {
5053
}
5154

5255
public function get($key) {
53-
return $this->driver->get($key);
56+
return $this->driver ? $this->driver->get($key) : null;
5457
}
5558

5659
public function set($key, $value) {
57-
return $this->driver->set($key, $value);
60+
return $this->driver ? $this->driver->set($key, $value) : null;
5861
}
5962

6063
public function delete($key) {
61-
return $this->driver->delete($key);
64+
return $this->driver ? $this->driver->delete($key) : null;
6265
}
6366

6467
public function close() {
65-
return $this->driver->close();
68+
return $this->driver ? $this->driver->close() : null;
6669
}
6770

6871
public function sessionId($id = null) {
69-
return $this->driver->sessionId($id);
72+
return $this->driver ? $this->driver->sessionId($id) : null;
7073
}
7174
}

system/session/php.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function __construct($options) {
5757
$domain = preg_replace('/^[^\.]*\./', '', $host);
5858
$name = str_replace('.', '', $domain);
5959
// skip if ip number
60-
if (! is_numeric($name)) {
60+
if ((! is_numeric($name)) && ($name != 'localhost')) {
6161
@ini_set('session.cookie_domain', ".$domain");
6262
session_set_cookie_params(0, '/', ".$domain");
6363
$sessionName = session_name($name);

0 commit comments

Comments
 (0)