Password Protected web site
Moderator: General Moderators
Password Protected web site
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?
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
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
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
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
Here's a simple code:
you have this on all pages of the site (just include() them):
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
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;
}
?>A very simple log in. Search around on google for some simple PHP Session/Cookie auth tutorials.
-Nay