Skip to content

Commit 449dfdd

Browse files
authored
Merge pull request #2 from doganoo/session
session improvement
2 parents ca23ccc + 21cceff commit 449dfdd

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/HTTP/Session.php

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,15 @@ public function remove(string $index): void {
6464
* @return string|null
6565
*/
6666
public function get(string $index, $default = null): ?string {
67-
return $_SESSION[$index] ?? $default;
67+
if (isset($_SESSION[$index])) {
68+
return $_SESSION[$index];
69+
}
70+
71+
if (null === $default) {
72+
return null;
73+
}
74+
75+
return $default;
6876
}
6977

7078
/**
@@ -91,7 +99,7 @@ public function regenerateSessionId(bool $deleteOldSession = true): bool {
9199
* @return bool
92100
*/
93101
public function isStarted(): bool {
94-
return false === (session_id() === '' || !isset ($_SESSION));
102+
return session_status() === PHP_SESSION_ACTIVE;
95103
}
96104

97105
/**

0 commit comments

Comments
 (0)