Forum Moderators: open

Message Too Old, No Replies

Javascript Password Protected Sites

         

Asnutting

9:55 pm on Dec 4, 2003 (gmt 0)

10+ Year Member



Hello here is what i have and what im trying to do. I currently have a site that has a very simple javascript that pops up a window and askes for a password if the password is correct it redirects you to ill call it "page A" if its wrong it goes to "page B"

My problem is that there is a back door to the script and all you have to do is to go directly to the websites address like "pagea.html" and it will let u in no problem

I would like to be able to use the users history to see if they have been redirected from the login site if not then they are directed back to the login site before the page loads.

However If i do that then every time the user with the correct password navigates inside the password protected area and when they go back to the main part of the protected area "pageA" they will be directed back to the login since they were not refered from the login site.

What can be used any ideas?

AsNutting

HocusPocus

1:46 am on Dec 5, 2003 (gmt 0)

10+ Year Member



If you really want to protect the contents of pagea.html, then don't use Javascript.

Not my field but I'm sure someone will come along and help you and point you in the right direction.

I think you need to put pagea in a separate folder and password protect it, possibly using .htaccess. Find out what server you are using and search for server .htaccess password protect.

mipapage

1:54 am on Dec 5, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Not sure if you have access to PHP, but here's a good article on how to Authenticate and Track Users with PHP [hotwired.lycos.com].

It goes a bit beyond what you are after but there are some very easy to integrate starter scripts there.

Asnutting

2:44 am on Dec 5, 2003 (gmt 0)

10+ Year Member



I am running of campus servers and I am not allowed a huge amount of access to the stuff all the access i have is to my area where i have my site stored.

HocusPocus

10:00 am on Dec 5, 2003 (gmt 0)

10+ Year Member



In page pageb, you could add a little protection by adding
<SCRIPT>
if(document.referrer!="http://YOURSERVER/page1.html")
{
document.location = "http://YOURSERVER/pagea.html"
}
</SCRIPT>