Auth0 Home Blog Docs

Redirect after login

Is there a way, maybe a rule or some php, to redirect to the previous page after logging in. Right now on our site it just takes you back to the login page but I would like to go back to whatever page they were on before they logged in, or at least to the homepage.

Hi there @seacrist, below is a document that talks exactly about the subject you are interested in when it comes to redirecting after login. When you get a minute give it a look and let me know if you have any questions! Thanks in advance!

I wanted to touchbase @seacrist and see if you had any additional questions that I could assist with on this subject? Thanks!

Sorry, I still haven’t been able to get it to work. I also tried to make a rule from here, https://auth0.com/docs/rules/guides/redirect, and had a rule that had this in it, but it would just redirect to the front-page without logging in.

function (user, context, callback) {
context.redirect = {
url: “https://ipqpubs.org/front-page/
};
return callback(null, user, context);
}

After talking further with our support team, you might have better luck implementing state or nonce in your application. It’s likely not redirecting effectively because it’s not being passed a token.

state optional (String) An arbitrary value that should be maintained across redirects. It is useful to mitigate CSRF attacks and for any contextual information (for example, a return URL) that you might need after the authentication process is finished. For more information, see State Parameter.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.