From b43638f8eef9a7872674f5241cc1f0ac757b53b5 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 5 Apr 2016 23:28:33 +0200 Subject: [PATCH] "remember me" in session does work now --- include/auth.php | 39 ++++++++------------------------------- include/session.php | 1 - 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/include/auth.php b/include/auth.php index a5b6432fff..4abff19710 100644 --- a/include/auth.php +++ b/include/auth.php @@ -5,35 +5,14 @@ require_once('include/security.php'); require_once('include/datetime.php'); function nuke_session() { - if (get_config('system', 'disable_database_session')) { - session_unset(); - return; - } new_cookie(0); // make sure cookie is deleted on browser close, as a security measure - - unset($_SESSION['authenticated']); - unset($_SESSION['uid']); - unset($_SESSION['visitor_id']); - unset($_SESSION['administrator']); - unset($_SESSION['cid']); - unset($_SESSION['theme']); - unset($_SESSION['mobile-theme']); - unset($_SESSION['page_flags']); - unset($_SESSION['submanage']); - unset($_SESSION['my_url']); - unset($_SESSION['my_address']); - unset($_SESSION['addr']); - unset($_SESSION['return_url']); - + session_unset(); } // login/logout - - - if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-params'))) || ($_POST['auth-params'] !== 'login'))) { if(((x($_POST,'auth-params')) && ($_POST['auth-params'] === 'logout')) || ($a->module === 'logout')) { @@ -41,6 +20,7 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p // process logout request call_hooks("logging_out"); nuke_session(); + new_cookie(-1); info( t('Logged out.') . EOL); goaway(z_root()); } @@ -90,8 +70,7 @@ if((isset($_SESSION)) && (x($_SESSION,'authenticated')) && ((! (x($_POST,'auth-p } authenticate_success($r[0], false, false, $login_refresh); } -} -else { +} else { if(isset($_SESSION)) { nuke_session(); @@ -209,13 +188,11 @@ else { } function new_cookie($time) { - if (!get_config('system', 'disable_database_session')) - $old_sid = session_id(); - session_set_cookie_params($time); + if ($time != 0) + $time = $time + time(); - if (!get_config('system', 'disable_database_session')) { - session_regenerate_id(false); - q("UPDATE session SET sid = '%s' WHERE sid = '%s'", dbesc(session_id()), dbesc($old_sid)); - } + $params = session_get_cookie_params(); + setcookie(session_name(), session_id(), $time, $params['path'], $params['domain'], $params['secure'], isset($params['httponly'])); + return; } diff --git a/include/session.php b/include/session.php index 12551efc42..8f9d64606c 100644 --- a/include/session.php +++ b/include/session.php @@ -69,7 +69,6 @@ function ref_session_destroy ($id) { if(! function_exists('ref_session_gc')) { function ref_session_gc($expire) { q("DELETE FROM `session` WHERE `expire` < %d", dbesc(time())); - //q("OPTIMIZE TABLE `sess_data`"); return true; }}