Answer the question
In order to leave comments, you need to log in
How to organize a redirect?
Personal account website. If they throw me a link to what's inside the personal account and when I click on the link I'm not logged in, then I'm redirected to the login page. But after I log in, it throws me to the main page, and not to the link I clicked on. How to solve it?
PS I get the transition link from $_SERVER['REQUEST_URI']
Let's say the transition link domen.ua/task/view/85
I have a TaskController class that is inherited from the BaseController base class. BaseController:
class BaseController {
public function __construct() {
$_SESSION['adress'] = $_SERVER['REQUEST_URI']; // тут я и записываю в сессию ссылку, по которой перешли. Понимаю что в сессию записывать не правильно
User::checkAuth();
}
}
function checkAuth() {
include 'config/config.php';
//если не авторизован, переадресовываем на страницу авторизации
if(!User::isAuth()) {
header("Location: ".$s_prefix."/user/login");
} else {
Registry::set('user', $_SESSION);
return true;
}
}
function isAuth() {
if(!isset($_SESSION['is_auth'])) return false;
if(!($_SESSION['is_auth'] === TRUE)) return false;
User::checkLive(); //проверяем, нужно ли убить сессию
return true;
}
public function actionLogin() {
// проверки всякие...
// если всё хорошо
if ($update) {
header("Location: " . $_SESSION['adress']);
unset($_SESSION['adress']);
} else {
$msg_title = "Ошибка";
$msg_cont = "Error 111";
}
}
Answer the question
In order to leave comments, you need to log in
When redirecting to the login page, you can pass a GET parameter to it with a link to the page to which the user will need to be redirected after logging in
As I understand it, when you follow the links in the personal account and you are not auto-removed, then you need to be redirected to the login page. Make a check, if there is no session, then throw it on the login page
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question