Is it possible to redirect user to "last visit page" after login ?? | Community
Skip to main content
Adilmo
Level 4
September 24, 2020
Solved

Is it possible to redirect user to "last visit page" after login ??

  • September 24, 2020
  • 2 replies
  • 910 views

Is it possible to redirect user to "last visit page" after login ??

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Suraj_Kamdi

@Adilmo Yes, we can.

For that, You need to write a servlet that will store the current path of that page using the request parameter.

Once your user logged in to the from login page then redirect to the last path using

request.getRequestDispatcher(lastpPath);

2 replies

Suraj_Kamdi
Community Advisor
Suraj_KamdiCommunity AdvisorAccepted solution
Community Advisor
September 24, 2020

@Adilmo Yes, we can.

For that, You need to write a servlet that will store the current path of that page using the request parameter.

Once your user logged in to the from login page then redirect to the last path using

request.getRequestDispatcher(lastpPath);
Suraj Kamdi
Manjunath_K
Level 7
September 24, 2020

@adilmo 

Assuming you are referring to website page login & if 'yes' then try to save only the current page url (location.pathname) on page load of each page(except login page) in browser cookie as encrypted string/encoded URI. after login success event redirect to the page url  present in the cookie which will be the last visited page url.