A Flash Developer Resource Site

Results 1 to 2 of 2

Thread: javascript password protect

  1. #1
    Member
    Join Date
    May 2008
    Posts
    33

    javascript password protect

    i have this javascript password protect on a page in my site and when i click on a link on that page and go back it makes me type in the password again to access the page. how can i make it so that it will remember me (and wont make me login everytime i go to the page) until i close my browser or leave the website.

    heres the javascript:

    Code:
    <script type="text/javascript">
    
    var password;
    var pass1 = "password"; // place password here
    
    password=prompt("Please Enter the Password","");
    
    if (password==pass1) 
      alert('Password is Correct!'); // file to open if password is correct
    else {
      window.location= "index.html"; // file to load if password is incorrect
    }
    // End -->
    </script>

  2. #2
    Bearded (M|G)od MyFriendIsATaco's Avatar
    Join Date
    Dec 2002
    Location
    Awesomeville.
    Posts
    3,045
    To answer your question, you'd need to use cookies.

    But to help you out, that is the worst security ever. Alls anyone needs to do is look at the source of the page and see the username/password, or even just look at the window.location line to see where it's redirecting to. Look into either using an .htpasswd for some basic authentication with minimal effort, or using PHP.

Posting Permissions

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




Click Here to Expand Forum to Full Width

HTML5 Development Center