Click here to Skip to main content
15,884,237 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
how should i prevent going back to previous page after logout using JavaScript.?

What I have tried:

I didn't find any solution for this.
Posted
Updated 3-Jul-20 0:15am
v2
Comments
Afzaal Ahmad Zeeshan 3-Jul-20 5:57am    
You can:

1. Remove the browser history using Windows History API
2. Prevent the browser back button event.
3. Close the tab.
4. Run a script on the previous page to check the session or the browser history state (if the next page was log out page, close the tab).

There are several options in which you can control this; and they all depend on the business requirements.
Member 14704249 3-Jul-20 6:01am    
Will you be able to provide code for it in JavaScript.
I just wanted to prevent user to go back in my website after successfully logged out
MadMyche 3-Jul-20 7:58am    
How are you managing login?
F-ES Sitecore 3-Jul-20 8:07am    
You need to disable caching on your pages so the browser needs to request them every time.

1 solution

This should not the way, Instead of that you should manage session in your condition after login.
1. Assign user session after login
2. Check for user session while opening any page of your application
3. Kill all active sessions during logout.

it will prevent authorized access after login
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900