Hi friends,
I am trying to develop a web application in which I have provided a facility for login and logout. I can allow user to log in succesfully, but when user clicks on the logout link and comes to login page and after that if he presses the browser's BACK button, he is directed to the previous page.I don't want to use any javascript function like history(). please provide some sample code of one or 2 pages.please????

6 Years
Discussion Span
Last Post by javaAddict

When you login, put the user name into the session: session.setAttribute("USERNAME", <username_of_the_user>); When you log out remove it: session.setAttribute("USERNAME", null); And in every page take the USERNAME from the session and check if it's null. If it is then who ever went to that page hasn't login:

String username = (String)session.getAttribute("USERNAME");
if (username==null) {
  // redirect to login page with message

The browser remembers the password when you try to login. It will not keep you logged in. And it remembers the password only at the computer that you saved it.
When you logout with the above code you will not be allowed to proceed unless you login again.
Of course it is unwise to save your password at a browser/computer that many people use.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.