@@ -19,22 +19,29 @@ class JwtSession implements SessionHandlerInterface
19
19
20
20
protected $ cookieDomain ;
21
21
22
+ protected $ path = "/ " ;
23
+
22
24
/**
23
25
* JwtSession constructor.
24
26
*
25
27
* @param $serverName
26
28
* @param $secretKey
27
29
* @param int $timeOutMinutes
28
30
*/
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 = " / " )
30
32
{
31
33
$ this ->serverName = $ serverName ;
32
34
$ this ->secretKey = $ secretKey ;
33
35
$ this ->timeOutMinutes = $ timeOutMinutes ?: 20 ;
34
36
$ this ->suffix = $ sessionContext ?: 'default ' ;
35
37
$ this ->cookieDomain = $ cookieDomain ;
38
+ $ this ->path = "/ " ;
36
39
}
37
40
41
+ /**
42
+ * @param bool $startSession
43
+ * @throws JwtSessionException
44
+ */
38
45
public function replaceSessionHandler ($ startSession = true )
39
46
{
40
47
if (session_status () != PHP_SESSION_NONE ) {
@@ -78,7 +85,13 @@ public function close()
78
85
public function destroy ($ session_id )
79
86
{
80
87
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
+ );
82
95
}
83
96
84
97
return true ;
@@ -176,7 +189,7 @@ public function write($session_id, $session_data)
176
189
self ::COOKIE_PREFIX . $ this ->suffix ,
177
190
$ token ,
178
191
(time ()+$ this ->timeOutMinutes *60 ) ,
179
- ' / ' ,
192
+ $ this -> path ,
180
193
$ this ->cookieDomain ,
181
194
false ,
182
195
true
0 commit comments