What is the best technique to return to the original page after logging in?

Asked 2 years ago, Updated 2 years ago, 41 views

For example, you walk around a page for a web service and enter a page that requires you to log inCotton

You will need to log in and return to the original page.

I don't know if there's a separate processing technique for the above situation, but which method is commonly used?

I'm curious if there is.

web javascript jsp

2022-09-21 14:37

1 Answers

It's simple. Remember url (referer) before login and redirect to url if login is successful.

There are many ways, but the usual way is

If you didn't log in at the time you needed to log in, send it like this

Also, if you successfully log in, read the query list next_url and redirect it.

It's no different from the stomach. Now you record that referrer in a session or input type hidden.

Then, if you succeed in logging in from the server, you can just read it and redirect it.

<input type="hidden" name="next_url" value="{Get referrer in server language}">
// Save current url in pre-redirect session

// Next, when you request to log in,
If (login successful) {
    redirect (url saved in session);
}

You can do it like this.

Some of the things you want to modify are if you redirect the url as it is, you can try an attack like csrf, so it's also good to filter it


2022-09-21 14:37

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.