Skip to content

Commit

Permalink
Conform PR codestyle and minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
bryanjhv committed May 8, 2017
1 parent c0acb3c commit 754f882
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
3 changes: 0 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ $app->get('/', function () {
$exists = isset($session->my_key);
$exists = isset($session['my_key']);

// Get All variable
$ses = $session->getIterator();

// Get a variable
$my_value = $session->get('my_key', 'default');
$my_value = $session->my_key;
Expand Down
44 changes: 23 additions & 21 deletions src/Slim/Middleware/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,28 @@ protected function startSession()
$settings['httponly']
);

$inactive = session_status() === PHP_SESSION_NONE; // ignore PHP_SESSION_DISABLED
if ($inactive) {
// when using $active = session_status() === PHP_SESSION_ACTIVE;
// this line never called, so the lifetime never ascending
if ($settings['autorefresh'] && isset($_COOKIE[$name])) {
setcookie(
$name,
$_COOKIE[$name],
time() + $settings['lifetime'],
$settings['path'],
$settings['domain'],
$settings['secure'],
$settings['httponly']
);
}
}
session_name($name);
session_cache_limiter(false);
if ($inactive) {
session_start();
}
$inactive = session_status() === PHP_SESSION_NONE;

if ($inactive) {
// Refresh session cookie when "inactive",
// else PHP won't know we want this to refresh
if ($settings['autorefresh'] && isset($_COOKIE[$name])) {
setcookie(
$name,
$_COOKIE[$name],
time() + $settings['lifetime'],
$settings['path'],
$settings['domain'],
$settings['secure'],
$settings['httponly']
);
}
}

session_name($name);
session_cache_limiter(false);
if ($inactive) {
session_start();
}
}
}

0 comments on commit 754f882

Please sign in to comment.