How to direct "BACK" button of the browser to the Login page after Logout?

Thread Solved

Join Date: Jul 2009
Posts: 26
Reputation: aditi_19 is an unknown quantity at this point 
Solved Threads: 0
aditi_19 aditi_19 is offline Offline
Light Poster

How to direct "BACK" button of the browser to the Login page after Logout?

 
0
  #1
Aug 4th, 2009
Hi,

I have created logout.php page which destroys all the session variables. Basically i want the the user to get directed to the Login page after logout button is pressed. But when the BACK button of the browser is pressed(even after logout), the user is still able to see other web pages.

How can i always direct Back button of the browser to Login page if the user has logged out?
Reply With Quote Quick reply to this message  
Join Date: Oct 2006
Posts: 1,066
Reputation: ardav will become famous soon enough ardav will become famous soon enough 
Solved Threads: 136
ardav's Avatar
ardav ardav is offline Offline
Veteran Poster

Re: How to direct "BACK" button of the browser to the Login page after Logout?

 
-1
  #2
Aug 5th, 2009
Don't try to code the BACK button, instead, use something like this at the head of every page:

  1. if(!isset($_SESSION['login']))header("Location: http://www.example.com/login.php");

Although you could use a relative or even absolute reference with header, I think I read somewhere that you should use the full url. Would cause a problem if testing both locally and remotely though. You could use:

  1. if(!isset($_SESSION['login']))header("Location: {$_SERVER['HTTP_HOST']}/login.php");

to enable the same code to run on local, testing and remote servers

However, I've used absolute references in the past without any ill effects, but I guess some other contributors here could give you good reasons why you shouldn't do this.
Last edited by ardav; Aug 5th, 2009 at 4:28 am.
Happy Humbugging Christmas
Reply With Quote Quick reply to this message  
Join Date: Jul 2009
Posts: 26
Reputation: aditi_19 is an unknown quantity at this point 
Solved Threads: 0
aditi_19 aditi_19 is offline Offline
Light Poster

Re: How to direct "BACK" button of the browser to the Login page after Logout?

 
0
  #3
Aug 5th, 2009
Hey,

Thanks a lot. It worked fine !
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for PHP
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC