My website has three pages:

  1. /
  2. /login
  3. /dashboard

When an user goes to /, if the user is logged, it redirects to /dashboard, but when is not logged, it redirects to /login.

But I want to know what is the best thing to do when a logged user goes to /login?

Should I redirect him to /dashboard? Or should I log him out and show the /login page?

1 Answer 1


I think if the user is already logged in, and they enter the URL for the login page, they should redirect to whatever page a user would be directed to AFTER they have logged in, so in your case, the dashboard page. You see this behaviour with most sites. Having said that, I think a cleaner approach is to have the index page, a login page (this may or may not be appropriate for your site) therefore, when the user goes to your root URL, they can login from that page. If they are already logged in, it automatically redirects to the the dashboard.

  • Agreed. Follow the user desired page and you can't fail. Assuming Login is the first page, then answer the following question: what is the desired behavior of someone who is logged in, to see home or to see /dashboard?
    – Jamezrp
    Commented Oct 27, 2014 at 23:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.