Skip to content

Commit

Permalink
Fix session_* functions call order
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanjhv committed May 13, 2016
1 parent cba861d commit 9bb90a0
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/Slim/Middleware/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,7 @@ public function call()
*/
protected function startSession()
{
if (session_id()) {
return;
}

$settings = $this->settings;
$name = $settings['name'];

session_set_cookie_params(
$settings['lifetime'],
Expand All @@ -80,20 +75,24 @@ protected function startSession()
$settings['secure'],
$settings['httponly']
);

if (session_id()) {
if ($settings['autorefresh'] && isset($_COOKIE[$name])) {
setcookie(
$name,
$_COOKIE[$name],
time() + $settings['lifetime'],
$settings['path'],
$settings['domain'],
$settings['secure'],
$settings['httponly']
);
}
}

$name = $settings['name'];
session_name($name);
session_cache_limiter(false);
session_start();

if ($settings['autorefresh'] && isset($_COOKIE[$name])) {
setcookie(
$name,
$_COOKIE[$name],
time() + $settings['lifetime'],
$settings['path'],
$settings['domain'],
$settings['secure'],
$settings['httponly']
);
}
}
}

0 comments on commit 9bb90a0

Please sign in to comment.