I recently made an interesting observation:
It seems that `session_start()` can return `true` even if the session was not properly created. In my case, the disk storage was full and so the session data could not be written to disk. I had some logic that resulted in an infinite loop when the session was not written to disk.
To check if the session really was saved to disk I used:
```
<?php
function safe_session_start() {
if (!@\session_start()) return false;
if (!isset($_SESSION['__validated'])) {
$_SESSION['__validated'] = 1;
@\session_write_close();
unset($_SESSION['__validated']);
@\session_start();
if (!isset($_SESSION['__validated'])) {
return false;
}
}
return true;
}
if (!safe_session_start()) {
}
?>
```
Took me quite a while to figure this out.
Maybe it helps someone!