Skip to content

Commit

Permalink
Silently fail to avoid sending headers early (#80)
Browse files Browse the repository at this point in the history
* Silently fail to avoid sending headers early

* Update dependencies
  • Loading branch information
g105b authored Jan 12, 2021
1 parent ffd186b commit a890bad
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
22 changes: 11 additions & 11 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public function __construct(
$config["save_path"] ?? self::DEFAULT_SESSION_PATH
);
$sessionName = $config["name"] ?? self::DEFAULT_SESSION_NAME;
$sessionStartAttempts = 0;

do {
$success = @session_start([
Expand All @@ -49,10 +50,11 @@ public function __construct(
]);

if(!$success) {
session_destroy();
$sessionStartAttempts++;
@session_destroy();
}
}
while(!$success);
while(!$success && $sessionStartAttempts <= 1);

$this->sessionHandler->open($sessionPath, $sessionName);
$this->store = $this->readSessionData() ?: null;
Expand Down

0 comments on commit a890bad

Please sign in to comment.