Click here to Skip to main content
15,919,358 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
If i click the back buton of a browser the website should logout
Posted
Updated 12-Dec-12 23:25pm
v3

Nope. Not remotely possible. Fix your code so that it doesn't cache logged in pages. You can't control the back button, your page will refresh same as before and any attempt to make the back button log out will be fraught with danger, and dumb design.
 
Share this answer
 
Comments
rameshtester 13-Dec-12 4:08am    
but in some bank websites they are having this feature.How they doin it
Christian Graus 13-Dec-12 4:10am    
No, I don't think they do. The fact is, if you write javascript to try to spot when the back button is pressed, it's trivial for a hacker to attack that. So, no-one should ever do it, it makes zero sense. The only logical way to do it, is if the whole site keeps track of what pages are requested in a session, and if it notices an order of requests that seems odd, it logs you out. A big job for a stupid result, only sensible for someone like a bank, trying to kick you out if you do ANYTHING that might mean you're trying to attack them.
rameshtester 13-Dec-12 4:15am    
if we does that means it will be a security issue for us.
Christian Graus 13-Dec-12 4:20am    
I don't understand. Why do you have a security issue ?
help me to solve the below problem

If i click the back buton of a browser the website should logout
 
Share this answer
 
Comments
Christian Graus 13-Dec-12 4:09am    
Dont post an answer that asks the question again
Hi,

In navigateLogin function, write ajax call to some server side function to clear your session and navigate to login page.

or

In navigateLogin fuction, navigate to login page and kill the session on the login page load.



<title>

function navigateLogin() {
//write ajax call here
}










 
Share this answer
 
Comments
rameshtester 13-Dec-12 4:30am    
the above code will fix the problem...
rameshtester 13-Dec-12 5:18am    
its not working
rameshtester 13-Dec-12 5:23am    
can u give me full code for this
Sampath Kumar Sathiya 13-Dec-12 8:35am    
you need to write the code in all the pages.

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