prevent hit the back button

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Chriss2004
Forum Newbie
Posts: 3
Joined: Thu Sep 09, 2004 7:04 pm

prevent hit the back button

Post by Chriss2004 »

hello.
I have an admin section on my page where i use sessions.

i want to prevent the user to click on the back button of the browser.

i don't want to use cookies, and someone told me that I could use a table to store sessions. Add a dateTime or timestamp field in the table which is refresed everytime a user visits a page. Every page then checks if the user is logged in by getting the relevant record from the database and then check if the session has expired by check he date field.

I don't know how to do this.
Can sombody pls help (guide) me? I'm new to php, and this is kind of vital.

Or perhaps there are other options.

Thx
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

viewtopic.php?t=23781 may help with database sessions.. try searching next time, please.

as for preventing backward walking, you can't effectively.
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

You could have the admin window open in a new window. When you open that window with JS, remove the toolbar which will remove the back button as well.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

pickle wrote:You could have the admin window open in a new window. When you open that window with JS, remove the toolbar which will remove the back button as well.
well, how would you stop me from using mouse gestures? :lol:
User avatar
pickle
Briney Mod
Posts: 6445
Joined: Mon Jan 19, 2004 6:11 pm
Location: 53.01N x 112.48W
Contact:

Post by pickle »

He said he wanted to stop users from clicking the back button, nothing about mouse gestures :). No back button is better than nothing I guess.
Real programmers don't comment their code. If it was hard to write, it should be hard to understand.
AngusL
Forum Contributor
Posts: 155
Joined: Fri Aug 20, 2004 4:28 am
Location: Falkirk, Scotland

Post by AngusL »

It would act as a subtle hint and an incentive. What you could do of course is right your own implementation of the internet explorer engine and force admins to use that for the admin stuff.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

that's a huge waste of time Angus. All because the script isn't fault tolerant enough to handle a historic page? blech.
hedge
Forum Contributor
Posts: 234
Joined: Fri Aug 30, 2002 10:19 am
Location: Calgary, AB, Canada

Post by hedge »

umm, why don't you want them to go back?

One way that I've seen that I don't believe is actually planned is to use a page with a meta tag with a refesh of 0 before your current page.
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post by timvw »

untill now, http://www.tonymarston.net/php-mysql/ba ... s.html#how is the easiest (and best working) solution i've seen :)
AGISB
Forum Contributor
Posts: 422
Joined: Fri Jul 09, 2004 1:23 am

Post by AGISB »

You could use javascript to open a new window on each link and close the old one in the process. As you always got a new window you have no back history.

Note: You can only close windows that you opened yourself. So the initial browser window the user comes in with can't be closed.

This of course only works when javascript is enabled.
Post Reply