Page 1 of 1
Password Protected web site
Posted: Fri Jan 09, 2004 7:23 am
by szms
I am planning to protect one of my web pages using Passowrd and for doing so I like to use Java Script. Could you please help me?
Posted: Fri Jan 09, 2004 7:29 am
by Nay
Woah, you've got to be kidding me. It you're going to make a secure site, Javascript is definately not the way to go - from my view at least. It's client-sided so that's the least trustable thing - ever.
I'm sure you had a reason why you wanted it to be in client side? You should explain a little more to let us help you.
-Nay
Posted: Fri Jan 09, 2004 7:40 am
by szms
I am not very much worried about security. Just want to keep my site from my curious friends. That's why wanted to use client side: javascript.
If you have so,me more idea about server side, you are welcome to inform me.
Posted: Fri Jan 09, 2004 7:46 am
by Nay
Ah, curious 'friends'. Not geeks I guess? If it was that simple maybe a simple security system would do. You can use Javascript's prompt() system.
A better simpler security system would be using cookies. That way your trusted friend won't have the annoyane of a Javascript prompt on everytime and your curious 'friends' are logged out.
Sessions, cookies, that's the way to go.
If 'they' sesiously aren't much a threat, maybe Javascript's a consideration.
-Nay
Posted: Fri Jan 09, 2004 7:53 am
by szms
I don't have much idea about session and cookies. Could you please let me know in detail about that.
Posted: Fri Jan 09, 2004 7:56 am
by Nay
Here's a simple code:
you have this on all pages of the site (just include() them):
Code: Select all
<?php
if(!isSet($_COOKIE['auth'])) {
header("Location: login.php");
exit;
}
?>
What it does is that it checks for the cookie named "auth" in the user's computer. If it is set, then you can get to the page, if it's not, PHP redirects to the login page.
A very simple log in. Search around on google for some simple PHP Session/Cookie auth tutorials.
-Nay
Posted: Fri Jan 09, 2004 8:17 am
by Pyrite
Try phpsecurepages.com
Posted: Fri Jan 09, 2004 9:29 am
by szms
I used the following code for entering the password but the window appears on the left top corner of IE. How can I show it in the middle of the page?
password=prompt('Please enter your password to view this page!',' ');