Skip to content

Commit cc1bc95

Browse files
committed
Update issue #7
1 parent 628c90b commit cc1bc95

File tree

1 file changed

+16
-3
lines changed

1 file changed

+16
-3
lines changed

src/JwtSession.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,29 @@ class JwtSession implements SessionHandlerInterface
1919

2020
protected $cookieDomain;
2121

22+
protected $path = "/";
23+
2224
/**
2325
* JwtSession constructor.
2426
*
2527
* @param $serverName
2628
* @param $secretKey
2729
* @param int $timeOutMinutes
2830
*/
29-
public function __construct($serverName, $secretKey, $timeOutMinutes = null, $sessionContext = null, $cookieDomain = null)
31+
public function __construct($serverName, $secretKey, $timeOutMinutes = null, $sessionContext = null, $cookieDomain = null, $path = "/")
3032
{
3133
$this->serverName = $serverName;
3234
$this->secretKey = $secretKey;
3335
$this->timeOutMinutes = $timeOutMinutes ?: 20;
3436
$this->suffix = $sessionContext ?: 'default';
3537
$this->cookieDomain = $cookieDomain;
38+
$this->path = "/";
3639
}
3740

41+
/**
42+
* @param bool $startSession
43+
* @throws JwtSessionException
44+
*/
3845
public function replaceSessionHandler($startSession = true)
3946
{
4047
if (session_status() != PHP_SESSION_NONE) {
@@ -78,7 +85,13 @@ public function close()
7885
public function destroy($session_id)
7986
{
8087
if (!headers_sent()) {
81-
setcookie(self::COOKIE_PREFIX . $this->suffix, null, (time()-3000) , '/', $this->cookieDomain);
88+
setcookie(
89+
self::COOKIE_PREFIX . $this->suffix,
90+
null,
91+
(time()-3000),
92+
$this->path,
93+
$this->cookieDomain
94+
);
8295
}
8396

8497
return true;
@@ -176,7 +189,7 @@ public function write($session_id, $session_data)
176189
self::COOKIE_PREFIX . $this->suffix,
177190
$token,
178191
(time()+$this->timeOutMinutes*60) ,
179-
'/',
192+
$this->path,
180193
$this->cookieDomain,
181194
false,
182195
true

0 commit comments

Comments
 (0)