Results 1 to 5 of 5

Thread: Help On New Cool Script!

  1. #1
    Join Date
    Jul 2005
    Location
    Oregon, USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Please Help On My New Script!

    I have a Password Protection Login script (http://javascript.internet.com/passw...s-source.html).
    Also, I have a Cookie Redirect script (http://javascript.internet.com/cooki...-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
    Last edited by hnpdyn; 07-30-2005 at 11:19 PM. Reason: Make It Better!

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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 on Dynamic Drive. It isn't as secure as server side login but, it is much better than the password script you mentioned.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Jul 2005
    Location
    Oregon, USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cool

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

    Thank You!
    Last edited by hnpdyn; 08-01-2005 at 07:44 AM.

  4. #4
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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. 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):
    Code:
    <html>
    <head>
    <title></title>
    <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>
    
    </head>
    <body>
    
    <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);
    }
    //CHANGE THE NUMBERS BELOW TO REFLECT YOUR USERNAME/PASSWORD
    if(usercode==117442800&&passcode==121006872)
    //CHANGE THE NUMBERS ABOVE TO REFLECT YOUR USERNAME/PASSWORD
    {
    SetCookie('passcode', password, exp)
    window.location=password+".htm"}
    else{
    alert("password/username combination wrong")}
    }
    </script>
    
    <form name="password1">
    <strong>Enter username: </strong>
    <input type="text" name="username2" size="15">
    <br>
    <strong>Enter password: </strong>
    <input type="password" name="password2" size="15">
    
    <input type="button" value="Submit" onClick="submitentry()">
    </form>
    
    </body>
    </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.
    Last edited by jscheuer1; 08-01-2005 at 03:58 PM.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  5. #5
    Join Date
    Jul 2005
    Location
    Oregon, USA
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thank you very much jscheuer1! You gave me exactly what I want!!!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •