From 4b799a69824f9f4a2ddb7df382b305b304b7d754 Mon Sep 17 00:00:00 2001 From: Bart Visscher Date: Wed, 5 Sep 2012 17:33:15 +0200 Subject: [PATCH] Make the lifetime of the remember login cookie --- config/config.sample.php | 5 ++++- lib/base.php | 2 +- lib/user.php | 7 ++++--- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/config/config.sample.php b/config/config.sample.php index 09eb6053c2..0c68594590 100644 --- a/config/config.sample.php +++ b/config/config.sample.php @@ -86,6 +86,9 @@ $CONFIG = array( /* Loglevel to start logging at. 0=DEBUG, 1=INFO, 2=WARN, 3=ERROR (default is WARN) */ "loglevel" => "", +/* Lifetime of the remember login cookie, default is 15 days */ +"remember_login_cookie_lifetime" => 60*60*24*15, + /* The directory where the user data is stored, default to data in the owncloud * directory. The sqlite database is also stored here, when sqlite is used. */ @@ -104,4 +107,4 @@ $CONFIG = array( 'writable' => true, ), ), -); \ No newline at end of file +); diff --git a/lib/base.php b/lib/base.php index 78f1f85f74..be93cb40e7 100644 --- a/lib/base.php +++ b/lib/base.php @@ -512,7 +512,7 @@ class OC{ } protected static function cleanupLoginTokens($user) { - $cutoff = time() - 60*60*24*15; + $cutoff = time() - OC_Config::getValue('remember_login_cookie_lifetime', 60*60*24*15); $tokens = OC_Preferences::getKeys($_COOKIE['oc_username'], 'login_token'); foreach($tokens as $token) { $time = OC_Preferences::getValue($user, 'login_token', $token); diff --git a/lib/user.php b/lib/user.php index 7de2a4b7fe..be8ddce88b 100644 --- a/lib/user.php +++ b/lib/user.php @@ -472,9 +472,10 @@ class OC_User { */ public static function setMagicInCookie($username, $token) { $secure_cookie = OC_Config::getValue("forcessl", false); - setcookie("oc_username", $username, time()+60*60*24*15, '', '', $secure_cookie); - setcookie("oc_token", $token, time()+60*60*24*15, '', '', $secure_cookie); - setcookie("oc_remember_login", true, time()+60*60*24*15, '', '', $secure_cookie); + $expires = time() + OC_Config::getValue('remember_login_cookie_lifetime', 60*60*24*15); + setcookie("oc_username", $username, $expires, '', '', $secure_cookie); + setcookie("oc_token", $token, $expires, '', '', $secure_cookie); + setcookie("oc_remember_login", true, $expires, '', '', $secure_cookie); } /**