Redirect to previous page after login

This commit is contained in:
grandeljay 2022-06-13 13:43:17 +02:00
parent 865236fa7e
commit dbffab099d
2 changed files with 7 additions and 1 deletions

View file

@ -148,11 +148,13 @@ class Page
'changelog',
'wishlist',
);
if (
!isset($_SESSION['user'])
&& isset($_SESSION['_GET']['page'])
&& !in_array($_SESSION['_GET']['page'], $ignorePower)
) {
$_SESSION['REDIRECT_URL'] = $_SERVER['REQUEST_URI'];
redirect(Page::PAGE_LOGIN);
}

View file

@ -40,7 +40,11 @@ if (isset($_POST['login'], $_POST['email'], $_POST['password'])) {
}
if (isset($_SESSION['user'])) {
redirect(Page::PAGE_HOME);
if (isset($_SESSION['REDIRECT_URL'])) {
redirect($_SESSION['REDIRECT_URL']);
} else {
redirect(Page::PAGE_HOME);
}
}
/**