ToughPal
ToughPal

Reputation: 2247

Changing the browser back button to go back twice

I have this web application which does the following as standard to all websites

How do I change at javascript or php level for the following

Thanks

Upvotes: 3

Views: 2266

Answers (4)

N S
N S

Reputation: 2603

There are a few ways to do this, the easiest: 1. Change the way your login process script redirects, if you change the location header then the web browser will ignore that page when the user goes back. In php it's as easy as

header("Location: http://www.google.com");

or 2.Use An AJAX login system, so rather than going from home->loginpage->profilepage you could have an in-page popup box that allows the user to login inside the homepage.

Either way, as an ease of use feature, you should probably send the user back to the homepage after login, and then there is no need to use the back button - on the new home page simply have "Welcome Bob, Profile Links Merged With Home Page, etc" added when a user is detected.

Hope that helps :)

Upvotes: 3

kwhohasamullet
kwhohasamullet

Reputation: 1128

You will just need to add some code to your login script that:

A) Checks if a user is logged in or not (probably using sessions)

if they are logged in redirect to the home page , If they are no logged in then load up the login page

Upvotes: 0

matpol
matpol

Reputation: 3074

You probably need use a header redirect in php to do this rather than try to use the back button.

Upvotes: 0

Josh
Josh

Reputation: 6322

there isn't a way to change the behaviour of the back button.

why don't you change the logic so that when the user clicks login the current page is passed through (as a parameter or use referrer) and then used to redirect once the user has logged in.

Upvotes: 0

Related Questions