Skip to content

Commit 5c0ac88

Browse files
committed
Session: session_start() return false on error since PHP 7.1
1 parent cd4026a commit 5c0ac88

1 file changed

Lines changed: 3 additions & 14 deletions

File tree

src/Http/Session.php

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,10 @@ public function start(): void
9797
session_id($id); // causes resend of a cookie to make sure it has the right parameters
9898
}
9999

100-
try {
101-
// session_start returns false on failure only sometimes
102-
Nette\Utils\Callback::invokeSafe(
103-
'session_start',
104-
[['read_and_close' => $this->readAndClose]],
105-
function (string $message) use (&$e): void {
106-
$e = new Nette\InvalidStateException($message);
107-
}
108-
);
109-
} catch (\Throwable $e) {
110-
}
111-
112-
if ($e) {
100+
if (!@session_start(['read_and_close' => $this->readAndClose])) { // @ is escalated to exception
101+
$message = Nette\Utils\Helpers::getLastError();
113102
@session_write_close(); // this is needed
114-
throw $e;
103+
throw new Nette\InvalidStateException($message);
115104
}
116105

117106
$this->initialize();

0 commit comments

Comments
 (0)