Skip to content

Commit 999f548

Browse files
committed
Session: session_start() return false on error since PHP 7.1
1 parent b184c45 commit 999f548

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

src/Http/Session.php

+4-15
Original file line numberDiff line numberDiff line change
@@ -103,21 +103,10 @@ public function start(): void
103103
session_id($id); // causes resend of a cookie to make sure it has the right parameters
104104
}
105105

106-
try {
107-
// session_start returns false on failure only sometimes
108-
Nette\Utils\Callback::invokeSafe(
109-
'session_start',
110-
[['read_and_close' => $this->readAndClose]],
111-
function (string $message) use (&$e): void {
112-
$e = new Nette\InvalidStateException($message);
113-
}
114-
);
115-
} catch (\Throwable $e) {
116-
}
117-
118-
if ($e) {
119-
@session_write_close(); // this is needed
120-
throw $e;
106+
if (!@session_start(['read_and_close' => $this->readAndClose])) { // @ is escalated to exception
107+
$message = Nette\Utils\Helpers::getLastError();
108+
@session_write_close(); // this is needed?
109+
throw new Nette\InvalidStateException($message);
121110
}
122111

123112
$this->initialize();

0 commit comments

Comments
 (0)