View Full Version : Help On New Cool Script!

07-30-2005, 11:13 PM
I have a Password Protection Login script (http://javascript.internet.com/passwords/multiple-users-source.html).
Also, I have a Cookie Redirect script (http://javascript.internet.com/cookies/cookie-redirect.html ) [setting by onclick the input checkbox]. When it set, next time when the visitor visit the page will automatic redirect to the other page.

Here is what I want, I want to put them together, I want the visitor to automatic redirect to the next page if they have been there.

I want to set cookie by UnOnloading the page or when clicking Sign In with Password Script - Insteak of onclick the Input Checkbox.

I think it will be a very script, - Please help me out!

Thank You Very Much

07-31-2005, 05:30 AM
That password script isn't very secure. All one need do is view the source to see the member names and passwords. The kind of set up you are talking about can better be done server side. Contact your host to see what server side secure logins are available and if users can be remembered with a server side cookie. Another, alternative would be to use a more secure password script such as the one here (http://www.dynamicdrive.com/dynamicindex9/password.htm) on Dynamic Drive. It isn't as secure as server side login but, it is much better than the password script you mentioned.

08-01-2005, 07:08 AM
I like the password protection you prefer. Also, I want to add cookie-redirect to this page (http://javascript.internet.com/cookies/cookie-redirect.html). Please help me out!

Thank You!

08-01-2005, 03:55 PM
Careful! Try it out with the wrong information first, once you've set the cookie using the right information, it will always take you to the protected page (in this case 'glob.htm', if available, page not found, if not) without prompting. In this example the username is 'Fred' and the password is 'glob'. Configuring a different name/password combo is still done as described here (http://www.dynamicdrive.com/dynamicindex9/password.htm). The cookie expiration can be set in the cookie code (Hint, set it to one (1) or zero (0) at first, in case you decide to change passwords, as once the cookie is set, it makes no difference what the password/username is):

<script type="text/javascript">
<!-- Original: Ronnie T. Moore -->
<!-- Web Site: The JavaScript Source -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

var expDays = 30;
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

function getCookieVal (offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
return null;
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();

var favorite = GetCookie('passcode');

if (favorite != null) {

window.location.href = favorite+".htm";



<script type="text/javascript">
//Encrypted Password script- By Rob Heslop
//Script featured on Dynamic Drive
//Visit http://www.dynamicdrive.com

function submitentry(){
password = document.password1.password2.value.toLowerCase()
username = document.password1.username2.value.toLowerCase()
passcode = 1
usercode = 1
for(i = 0; i < password.length; i++) {
passcode *= password.charCodeAt(i);
for(x = 0; x < username.length; x++) {
usercode *= username.charCodeAt(x);
SetCookie('passcode', password, exp)
alert("password/username combination wrong")}

<form name="password1">
<strong>Enter username: </strong>
<input type="text" name="username2" size="15">
<strong>Enter password: </strong>
<input type="password" name="password2" size="15">

<input type="button" value="Submit" onClick="submitentry()">

</html>Also, you can always delete cookies to start over, but your users may not know that so, get it worked out locally before going live.

08-04-2005, 08:47 AM
Thank you very much jscheuer1! You gave me exactly what I want!!!