Add Session::clear method

- Replace manual session clear by method in mod/manage
This commit is contained in:
Hypolite Petovan 2019-10-06 11:21:54 -04:00
parent 4a5dfefacc
commit e5fbaf6a00
2 changed files with 11 additions and 18 deletions

View file

@ -70,24 +70,8 @@ function manage_post(App $a) {
if (!DBA::isResult($user)) { if (!DBA::isResult($user)) {
return; return;
} }
unset($_SESSION['authenticated']);
unset($_SESSION['uid']); Session::clear();
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::setAuthenticatedForUser($a, $user, true, true); Session::setAuthenticatedForUser($a, $user, true, true);

View file

@ -99,6 +99,14 @@ class Session
unset($_SESSION[$name]); unset($_SESSION[$name]);
} }
/**
* Clears the current session array
*/
public static function clear()
{
$_SESSION = [];
}
/** /**
* @brief Sets the provided user's authenticated session * @brief Sets the provided user's authenticated session
* *
@ -107,6 +115,7 @@ class Session
* @param bool $login_initial * @param bool $login_initial
* @param bool $interactive * @param bool $interactive
* @param bool $login_refresh * @param bool $login_refresh
* @throws \Friendica\Network\HTTPException\ForbiddenException
* @throws \Friendica\Network\HTTPException\InternalServerErrorException * @throws \Friendica\Network\HTTPException\InternalServerErrorException
*/ */
public static function setAuthenticatedForUser(App $a, array $user_record, $login_initial = false, $interactive = false, $login_refresh = false) public static function setAuthenticatedForUser(App $a, array $user_record, $login_initial = false, $interactive = false, $login_refresh = false)