View Full Version : Locking Pages?

08-08-2004, 09:47 AM

I wanted to ask if there is a way i guess to perhaps "lock" pages with some sort of javascript? I want to make my website so that if a user wanted to view other pages besides the homepage, the login page would be generated and they would have to log in first, then they would be allowed to be view the other pages.

Also, after the user has logged in, they will see the URLs of the pages besides the homepage. The next time the user returns to my website, if the user decides to just type in the URLs of the other pages besides the homepage, I want the login page to be prompted, thus preventing users from just viewing my website without logging in.

Lastly, I wanted to also ask if the "lock" javascript would be the same to prevent the user from clicking the "BACK" button and returning to the website pages AFTER they have logged out?? If the script is not the same, what would it be?

Can anyone help me with a script to prevent this??

Thanks in advance. Your help is greatly appreciated.


08-08-2004, 03:58 PM
You can use document.cookie to set a cookie when logging in and then check on each page whether the cookie exists or redirect to the loggin page otherwise, but that is no safe protection, so you can't have certain users be disallowed on the pages.

08-08-2004, 04:43 PM
Server side scripting is a tool to be used for this task.
Javascript can not provide you a reliable solution.
Find out which language is supported by your host and post this question in appropriate server side sub-forum.

08-08-2004, 11:00 PM
Hi. I think i posted this question in the wrong forum. PLEASE disregard this post. I have reposted my question in the ASP forum. If you would like to help me, please respond to my post in the ASP FORUM. THanks. Sorry about this inconvenience.