From e5fbaf6a0067c0c3ca9b8c0f1042e9445a1ad14d Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 6 Oct 2019 11:21:54 -0400 Subject: [PATCH] Add Session::clear method - Replace manual session clear by method in mod/manage --- mod/manage.php | 20 ++------------------ src/Core/Session.php | 9 +++++++++ 2 files changed, 11 insertions(+), 18 deletions(-) diff --git a/mod/manage.php b/mod/manage.php index 09f553c61d..a1ca87e963 100644 --- a/mod/manage.php +++ b/mod/manage.php @@ -70,24 +70,8 @@ function manage_post(App $a) { if (!DBA::isResult($user)) { return; } - 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['return_path']); - if (!empty($_SESSION['submanage'])) { - unset($_SESSION['submanage']); - } - if (!empty($_SESSION['sysmsg'])) { - unset($_SESSION['sysmsg']); - } - if (!empty($_SESSION['sysmsg_info'])) { - unset($_SESSION['sysmsg_info']); - } + + Session::clear(); Session::setAuthenticatedForUser($a, $user, true, true); diff --git a/src/Core/Session.php b/src/Core/Session.php index b44ff3e2ea..3a0da3ab08 100644 --- a/src/Core/Session.php +++ b/src/Core/Session.php @@ -99,6 +99,14 @@ class Session unset($_SESSION[$name]); } + /** + * Clears the current session array + */ + public static function clear() + { + $_SESSION = []; + } + /** * @brief Sets the provided user's authenticated session * @@ -107,6 +115,7 @@ class Session * @param bool $login_initial * @param bool $interactive * @param bool $login_refresh + * @throws \Friendica\Network\HTTPException\ForbiddenException * @throws \Friendica\Network\HTTPException\InternalServerErrorException */ public static function setAuthenticatedForUser(App $a, array $user_record, $login_initial = false, $interactive = false, $login_refresh = false) -- 2.39.5