Click to See Complete Forum and Search --> : Passwords and Cookies
sinhart
12-27-2002, 05:02 PM
I am very new to js and haven't done much more than just cut & paste free scripts.
I have been asked to create a "Members Only" area on our Moose page and am considering using gatekeeper or a simular script.
The only problem with all the scripts that I have found so far is that you must enter the password everytime you want to view the protected page.
Is there a script somewhere that will allow the option of saveing the password on the users machine and therefore allow instant access the next time the user visits from the same machine?
5sisters
12-29-2002, 02:19 PM
Try here
http://javascript.internet.com/passwords/
the 3rd example down is a script for password protection which recognises cookies
http://javascript.internet.com/passwords/cookie.html
Charley Maxwell
sinhart
12-29-2002, 03:13 PM
Thank You. I thought I had looked at everything at the JavaScriptSource but have missed this one somehow. Thanks again.
Sinhart
sinhart
12-29-2002, 03:31 PM
Well this doesn't really work. Anyone can enter two different words in the first two boxes and the concantanated word in the third box to get in. I would rather set the password myself and when the prompt comes up, check for the cookie and redirect if present or if not present, redirect to the page that sets the cookie when the password is entered correctly. Does this make any sence or am I just hoping for too much? Thanks anyway though.
Sinhart
:confused:
Beach Bum
12-29-2002, 04:08 PM
no, you are not hoping for too much. you can store the password in a cookie, then when the visitor comes back to the page if the cookie is not present give them the password prompt. when they enter the password, set the cookie. if a cookie is present just go to the page name specified in the cookie. the problem will be if they enter an invalid name for the password, then you will get a page not found and be stuck in a loop because of the cookie (which the script will not know to be a bad name). if you put a name in the script to validate against, then anyone who looks at the script will have the password.
just a question of what you want to do.
sinhart
12-29-2002, 05:18 PM
Thanks for your input. Actually I think they would get a 404 File not found instead of an endless loop. Nevertheless I have just been informed that the funds have been allocated to purchase webspace. I can write this script with perl but didn't have a cgi-bin on the free server I was demoing the site on so couldn't demo the complete site.
I would like to thank everyone for the replies and will still be around to help out if possible.
Sinhart
:p
Beach Bum
12-29-2002, 06:16 PM
yea - i meant an endless loop of the 404 page each time they visited because the cookie would have the invalid page.
glad you have a solution.