1
0
mirror of https://github.com/moparisthebest/wallabag synced 2024-11-23 17:42:15 -05:00

fix for long lasting session

This commit is contained in:
Dmitry Sandalov 2013-12-21 23:39:45 +04:00
parent 5c8d438c08
commit a0aa150418
2 changed files with 11 additions and 3 deletions

View File

@ -32,6 +32,8 @@ class Session
// If the user does not access any page within this time, // If the user does not access any page within this time,
// his/her session is considered expired (3600 sec. = 1 hour) // his/her session is considered expired (3600 sec. = 1 hour)
public static $inactivityTimeout = 3600; public static $inactivityTimeout = 3600;
// Extra timeout for long sessions (if enabled) (82800 sec. = 23 hours)
public static $longSessionTimeout = 82800;
// If you get disconnected often or if your IP address changes often. // If you get disconnected often or if your IP address changes often.
// Let you disable session cookie hijacking protection // Let you disable session cookie hijacking protection
public static $disableSessionProtection = false; public static $disableSessionProtection = false;
@ -106,6 +108,7 @@ class Session
$password, $password,
$loginTest, $loginTest,
$passwordTest, $passwordTest,
$longlastingsession,
$pValues = array()) $pValues = array())
{ {
self::banInit(); self::banInit();
@ -118,7 +121,11 @@ class Session
$_SESSION['username'] = $login; $_SESSION['username'] = $login;
// Set session expiration. // Set session expiration.
$_SESSION['expires_on'] = time() + self::$inactivityTimeout; $_SESSION['expires_on'] = time() + self::$inactivityTimeout;
if ($longlastingsession) {
$_SESSION['longlastingsession'] = self::$longSessionTimeout;
$_SESSION['expires_on'] += $_SESSION['longlastingsession'];
}
foreach ($pValues as $key => $value) { foreach ($pValues as $key => $value) {
$_SESSION[$key] = $value; $_SESSION[$key] = $value;
} }
@ -136,7 +143,7 @@ class Session
*/ */
public static function logout() public static function logout()
{ {
unset($_SESSION['uid'],$_SESSION['ip'],$_SESSION['expires_on'],$_SESSION['tokens'], $_SESSION['login'], $_SESSION['pass'], $_SESSION['poche_user']); unset($_SESSION['uid'],$_SESSION['ip'],$_SESSION['expires_on'],$_SESSION['tokens'], $_SESSION['login'], $_SESSION['pass'], $_SESSION['longlastingsession'], $_SESSION['poche_user']);
} }
/** /**

View File

@ -678,7 +678,8 @@ class Poche
$user = $this->store->login($login, Tools::encodeString($password . $login)); $user = $this->store->login($login, Tools::encodeString($password . $login));
if ($user != array()) { if ($user != array()) {
# Save login into Session # Save login into Session
Session::login($user['username'], $user['password'], $login, Tools::encodeString($password . $login), array('poche_user' => new User($user))); $longlastingsession = isset($_POST['longlastingsession']);
Session::login($user['username'], $user['password'], $login, Tools::encodeString($password . $login), $longlastingsession, array('poche_user' => new User($user)));
$this->messages->add('s', _('welcome to your poche')); $this->messages->add('s', _('welcome to your poche'));
Tools::logm('login successful'); Tools::logm('login successful');
Tools::redirect($referer); Tools::redirect($referer);