The configuration file setting of the page requires login before browsing,
I hope to be redirected directly back to this page after logging in,
But in the action on the login page, I cannot get the Referer before login. How to deal with this situation?
When you are not logged in, the page that requires login will be redirected to the login page. At this time, the previously requested URL will be saved in the session.
If you go to the / route after logging in, you need to go to security
When the login fails, the requested URL will be saved under default_secutrity_target. In other cases, the default is /
What you mean is that when a non-logged-in user visits any page that requires login, he or she will be redirected to the login page. After successful login, he or she will be redirected back to the page he originally wanted to visit, right?
Get the referer when the user is redirected to the login page for the first time. When the user login form is submitted to the login page, pass this referer, such as using hidden input, and jump to the referer after successful login; if the login fails, then Return to the login page and pass the referer again. (Loop the above operations)
The login process will be much simpler if you use ajax