File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes HTML, CSS and JavaScript and the fly likes javascript Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "javascript" Watch "javascript" New topic



Joined: Mar 28, 2005
Posts: 23

Can anyone solve this requirement?
When the user clicks logout from his account and then clicks back button in the browser to access his account, he should be notified to login again.

How to solve this using javascript/html?
Ulf Dittmer

Joined: Mar 22, 2005
Posts: 42965
What happens whne you click the Back button is up to the browser - most of them will just re-display the previous page, and not load the URL again. If you want to prevent that, you can POST the logout request. In that case the browser should notify the user that the page will actually be retrieved from the server, at which point you can redirect to the login page.
Using JS you could mess around with the local cache -I think it's called window.history or something similar- and prevent the user from going back.
[ August 18, 2005: Message edited by: Ulf Dittmer ]
Yuriy Zilbergleyt
Ranch Hand

Joined: Dec 13, 2004
Posts: 429
I'd just set the headers for every page to not cache.

This is what I do in Servlets/JSP:

response.setHeader("Cache-Control", "no-cache");
response.setHeader("Pragma", "no-cache");

I agree. Here's the link:
subject: javascript
It's not a secret anymore!