Click to See Complete Forum and Search --> : !!!need Help With Password Protection!!!


Jick
02-06-2003, 07:41 PM
Hello,
Can any one give me a link or show me what the best way
is to password protect a website with javascript. I would like it to have it so there can be many users/passwords and i would like it to be in a form to login and also very secure as possible. If also possible i would like the users to have the option of setting a cookie to automaticly log them in next time. :confused:

Zach Elfers
02-06-2003, 09:48 PM
Please note that JavaScript is NOT secure and there is no way to make it secure.

Zach Elfers
02-06-2003, 10:01 PM
<script language="JavaScript" type="text/JavaScript">
<!--
var user = new Array("user1","user2","user3");
var pwds = new Array("a","b","c");
function login(form) {
for (a = 0; a < users.length; a++) {
if (form.username.value == user[a] && form.password.value == pwds[a]) {
self.location.href = "access.html";
}
else {
alert("Access Denied! Try again!");
}
}
}
//-->
</script>
...
<form onSubmit="login(this);return false;">
<input type="text" name="username">
<br>
<input type="password" name="password">
<p>
<input type="submit" value="Login">
</form>