Skip to content

Commit 43764e0

Browse files
committed
Fix error - header already sent (2)
1 parent d0da8d0 commit 43764e0

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/JwtSession.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,9 @@ public function close()
8080
public function destroy($session_id)
8181
{
8282
if (headers_sent()) {
83-
return false;
83+
setcookie(self::COOKIE_PREFIX . $this->suffix, null);
8484
}
8585

86-
setcookie(self::COOKIE_PREFIX . $this->suffix, null);
8786
return true;
8887
}
8988

@@ -174,11 +173,10 @@ public function write($session_id, $session_data)
174173
$data = $jwt->createJwtData($this->unSerializeSessionData($session_data), $this->timeOutMinutes * 60);
175174
$token = $jwt->generateToken($data);
176175

177-
if (headers_sent()) {
178-
return false;
176+
if (!headers_sent()) {
177+
setcookie(self::COOKIE_PREFIX . $this->suffix, $token);
179178
}
180179

181-
setcookie(self::COOKIE_PREFIX . $this->suffix, $token);
182180
return true;
183181
}
184182

0 commit comments

Comments
 (0)