[Webinar] Streamline your web hosting managementRegister Today


Preventing browser from going back

Posted on 1999-12-04
Medium Priority
Last Modified: 2013-12-25
I have a page that allows a user to specified a user name and password to genrate a free account on a system. The free account is an incentive for the user to fillout a survey.

Question 1: How do I prevent users from going directly to the free account page without filling the survey (in case they know the URL).

Question 2: How do I prevent the user from using the Back button to create multiple account.
Question by:moonrise

Expert Comment

ID: 2256150
This is probably too little info for an answer... will do for a comment, tho'

Prevent : use cookies. Set the cookie after the survey is
filled and check it on entry. The same applies for pressing "back" - the user can press Back, but the cookie is already set
and the survey says "Sorry... Can only be done once."

Author Comment

ID: 2256152
That sounds like a good idea but this survey wil actually be done at a public kiosk. Would that be a problem since the same PC must be allowed to run the survey again and again. Thank you.

Expert Comment

ID: 2256769
The cookie solution will not work on a public kiosk (unfortunately).

If your server is IIS, you can probably create an active server page application which would do what you would like.

Other than that, you are probably looking at some sort of CGI script.

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.


Author Comment

ID: 2256946
CGIs are OK, I already use them but I am not sure what needs to be done in the CGI to do that. I am actually using ISAPI DLLs developed in Delphi.

Expert Comment

ID: 2259401
Pretty much what you need to do is to create something that "maintains state".  That's why I suggested IIS/ASP.

Not sure how you would do this with CGI, but for question 1, you need to check the "referrer" page to be sure it's coming from your login page.  This is a server side variable, and a CGI script should be able to pick it up.  If the page request is not coming from your login page, redirect the request to the login page.

As far as question 2 goes, I am sure you can come up with something which will stop an immediate return to the login page, but how do you stop someone from surfing around for a couple of pages and coming back?  Again that's why I was looking at IIS.  If a session is established in IIS, you can test for a variable which will exist for a defined amount of time and refuse any requests in that time period.

Don't know if this is helpful.  Just trying to point you in the right direction.


Accepted Solution

jhurst earned 400 total points
ID: 2259535
1) The second page needs to be generated by a cgi rather than just html.  The cgi can cxhecjk the HTTP_REFERER and ensure that it is called from the page that asks your questions.

2) The simplest way to disable back is to use a
<meta http-equiv="refresh" content="0; url=http://thepageyouwant">
You generate a page containing the above line, this then immediately transfers to thepageyowant.  Now, if the user hits back, he/she gets to the page with the refresh again and so is re-sent to your page.

In fact 2) is such a pain for many that they do a content="1; " not 0 so that there is a delay, giving people a chance to hit the back.  In your case you will use this annoying feature.

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ready to get certified? Check out some courses that help you prepare for third-party exams.
Over time, the online landscape has altered considerably, but that’s nothing compared to the up-and-coming trends that will shape the web design industry in the coming year. Keep reading to find out which trends will shape B2B web design in 2018.
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses
Course of the Month8 days, 13 hours left to enroll

611 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question