Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes HTML, CSS and JavaScript and the fly likes controlling going back to previous page after logout Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "controlling going back to previous page after logout" Watch "controlling going back to previous page after logout" New topic
Author

controlling going back to previous page after logout

bhaskar ganapathi
Greenhorn

Joined: Aug 11, 2005
Posts: 15
Hi all


after logout from web site , one can go back to the previous pages using browser's back button.

any idea how to controll it.

what i need is after logout if some one clicks the browser's backbutton it should go to login page.

thanks

Bhaskar G


Bhaskar G
Michael Ernest
High Plains Drifter
Sheriff

Joined: Oct 25, 2000
Posts: 7292

Moving this to HTML/Javascript forum.


Make visible what, without you, might perhaps never have been seen.
- Robert Bresson
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
If you are working on Jsp or servlet, just explore Session tracking mechanism ...


Thanks & regards, Srini
MCP, SCJP-1.4, NCFM (Financial Markets), Oracle 9i - SQL ( 1Z0-007 ), ITIL Certified
bhaskar ganapathi
Greenhorn

Joined: Aug 11, 2005
Posts: 15
i am working on jsp. i tried so many cache control mechanisum

like adding following code on top of each jsp


<%

response.setHeader("Cache-Control","no-store");
response.setHeader("Pragma","no-cache");
response.setDateHeader ("Expires", 0);

%>

but it did not work. after log out if i click browser back button

it shows pages that is protected by session
Srinivasa Raghavan
Ranch Hand

Joined: Sep 28, 2004
Posts: 1228
Why not you check for the session variable like the userId or any thing .. if it's null you can redirect the user to home page.
[ September 23, 2005: Message edited by: Srinivasa Raghavan ]
bhaskar ganapathi
Greenhorn

Joined: Aug 11, 2005
Posts: 15
when i click browser back button it is not at all hitting the server.

it is entirely due to browser cache.
Vidya Ramakrishnan
Greenhorn

Joined: Jul 08, 2008
Posts: 14
I am working in javascript on the client side and php on the server side

can anyone please help me with javascript for the above mentioned problem???

Thanks...
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
Javascript? That's already too late then. The response is already arrived at the client at the moment JS starts to run.

Just set the appropriate response headers using HTML or PHP.

As you're here at a HTML forum, here's the HTML equivalent:

Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
I should add, this does not prevent the user from actually going back to the previous page (which is simply impossible). It just prevents the previous page being viewed from the browser cache, which would make the user think: "Hey, I am already logged out, why do I still see the secured page?!". Adding the response headers prevents the page being cached in the browser, so the browser is forced to actually fire a request to the server, where you can easily check if the user is logged in or not and handle the response accordingly.
Vidya Ramakrishnan
Greenhorn

Joined: Jul 08, 2008
Posts: 14
the cache-control mechanism doesnt work for me. I tried using session variables in php --session_register and session_destroy;
But still I am not able to go ahead.
Anyone please help me with steps in using session variables.

I am new to php. So it is a bit difficult for me.Please help

Thanks..
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
This isn't a PHP forum.
 
wood burning stoves
 
subject: controlling going back to previous page after logout
 
Similar Threads
upon click of back button, go to logout page
Refresh page once
Login Problem
creating the page Expired
Disable browser back button and refresh in jsp page