Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Cookies/sessions? - how do i set it?

Status
Not open for further replies.

Lenzcuvasch

Technical User
Mar 16, 2002
25
0
0
MY
Hi,

I have a page. And how it supposed to work is that once someone have visited that page, he can't re-visit it again - even with 'back' button. It'll display a message 'you are not allowed to revisit this page'

I suppose it had something todo with cookies

Thanks to anyone who is willing to help.

Fariz
 
Cookies aren't really the way to go with this one. They are easily fiddled with by even the less savvy users who know about them. If someone wants to revisit the page they're gonna find a way so make it a little more work for them.

Put this JavaScript into the page you are protecting. If your user attempts to get into that page from anywhere except the previous page (or any specified page) they will get an alert and a redirect. Of course you can get rid of the redirect and just leave them where they are too.

var requiredfrom = "index.html"; // required prev. page
if (document.referrer.indexOf(requiredfrom) == -1) {
alert("You are not allowed to revisit this page!);
window.location=requiredfrom;
}


For an added security, but a little more work for you, put each JavaScript into it's own JS file and place the folowing into the head of your protected html page:


<script language=&quot;JavaScript&quot; src=&quot;Secure_1.js&quot;></script>

The JavaScript will not show up on the page and thus will require a little more work for the user to get around.

Good luck!
rich
hire me in Central Jersey!!
 
billy -

It didnt seem 2 be working. The alert pops up when I first accessed the page.

it supposed to be like this
1st page - click link - second page (if click 'back', alert or stay at the page)

any help would be appreciated
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top