T
T
tigra2016-08-26 15:23:04
Yii
tigra, 2016-08-26 15:23:04

How to return to YII2 address entered before authorization?

A person follows the link, but he is not authorized, he is redirected to the login form.
After he logs in, he should be redirected to the address he wanted to go to.
How to implement such a thing? I started looking at Url::remember(), but I still don't understand how it works
Url::remember('', 'saveUrl') swears, I don't understand why.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
M
Maxim Timofeev, 2016-08-26
@tigroid3

return $this->redirect(Yii::$app->request->referrer);

or
return $this->goBack();

A
Arthur, 2016-08-26
@ArturF

Redirect to `Yii::$app->user->returnUrl`

W
WQP, 2016-08-26
@WQP

When redirecting to the login page, specify in GET the page from which you went

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question