| | |
How to direct "BACK" button of the browser to the Login page after Logout?
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved |
•
•
Join Date: Jul 2009
Posts: 26
Reputation:
Solved Threads: 0
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?
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?
Don't try to code the BACK button, instead, use something like this at the head of every page:
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:
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.
PHP Syntax (Toggle Plain Text)
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:
PHP Syntax (Toggle Plain Text)
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
![]() |
Similar Threads
- Updated : Simple ASP.Net Login Page (ASP.NET)
- How to disable Back button of IE when executing welcome.aspx page? (ASP.NET)
- Redirecting user to a login page (JavaScript / DHTML / AJAX)
- Login page button(visual basic) (ASP.NET)
- disable back button in the browser using javascript (JavaScript / DHTML / AJAX)
- Validating radio button selection for login redirect (JavaScript / DHTML / AJAX)
- Back button in browser (ASP.NET)
- Linking from the login page to other pages (PHP)
Other Threads in the PHP Forum
- Previous Thread: Creating an image made of other images
- Next Thread: create PDF in HTML
| Thread Tools | Search this Thread |
Tag cloud for PHP
.htaccess access ajax apache api array beginner binary broken cakephp checkbox class cms code cron curl database date directory display download dynamic ebooks echo email error file files folder form forms function functions google href htaccess html image include insert integration ip java javascript joomla limit link login loop mail mediawiki menu mlm mod_rewrite multiple mysql number oop parse paypal pdf php phpincludeissue phpmyadmin problem query radio random recursion regex remote script search server sessions sms soap source space speed sql structure subdomain syntax system table tag tutorial update upload url validation validator variable vbulletin video web white xml youtube






