wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes Clearing the session. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Clearing the session." Watch "Clearing the session." New topic
Author

Clearing the session.

Patrick Nshimba
Greenhorn

Joined: Nov 15, 2010
Posts: 3
Hi,
my name is Patrick and im new in Java script, im designing a website as part of my final year project,
i have a problem with the sessions, how can i clear the session when i don't log off but just use the browser back button,
so that when i want to go back to that page , it must take me to the login page.?
Help needed quickly.
Praneeth Yeri
Greenhorn

Joined: Oct 07, 2010
Posts: 11
I am assuming that you are using a J2EE Server to serve your web pages. You should always provide a Session time out in the web.xml. If a user tries to close a window, without properly logging off, then the container automatically kills the sessions which are past the session time out.

Also if you feel that you should be redirecting to the login page, if there is no session, then have a filter in the web.xml that checks for valid session and performs the redirect.
Patrick Nshimba
Greenhorn

Joined: Nov 15, 2010
Posts: 3
Hi Praneeth Yeri, is there any script that is there as an example i can refer to?
Praneeth Yeri
Greenhorn

Joined: Oct 07, 2010
Posts: 11
For mentioning the Session Time out in web.xml, You can do the following in the web.xml file.

Where session-timeout
<session-timeout>: The timeout for a session in minutes.

Patrick Nshimba
Greenhorn

Joined: Nov 15, 2010
Posts: 3
sorry im using php and java scripts.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Java and JavaScript are two different things.



The back button retrieves the page from the user's cache. There is no way to prevent it when you do not set the proper no cache headers. http://www.mnot.net/cache_docs/

Eric

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Clearing the session.