Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Jun 2002
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Cookie Help - Log-on vs Registration

    Hi there

    I want to store a cookie that determines if a user has been to site and registered.

    If they have registered when the user clicks a "Download" graphic the cookie must either send them to a log-in page saying Welcome back "FirstName" please enter your username and password or to a Register Page to register. Once they have registered a password and username are sent to them.

    I have got js to delete, get and set the cookie.

    All I need is script that will check the cookie, redirect and display the username if necessary.

    I am a beginner and do not really understand this stuff.

    This is the code that I got with the other js but do not know how to modify it.

    function DoTheCookieStuff()
    {
    username=getCookie('username');
    if (username!=null)
    {
    alert('Hi there '+username+' - Good to see you again!')
    }
    else {
    username=prompt('Hi - this is your first visit to my page - please enter your name.',"");
    setCookie('username',username,365)}
    }


    Please help

  • #2
    Senior Coder
    Join Date
    Jun 2002
    Location
    41 8' 52" N -95 53' 31" W
    Posts
    3,660
    Thanks
    0
    Thanked 0 Times in 0 Posts
    First of all, I would like to quote what Dave said. He is absolutely 100% correct!

    Ok, now if you you really want users to "register" and then be able to "login" to your website, then javascript won't be able to accomplish what you want.

    Javascript can only interact with the browser that the client has installed - it cannot save information between visits to your website. Cookies can do this (individually), but as an example, if your brother (on another computer) logs into the website, there would be absolutely no way for you to know, since with javascript you cannot store this information on the server.

    PHP is the most popular server-side language- however ASP, Perl, and a host of other server-side scripting languages will all accomplish the same things... things that a CLIENT-SIDE scripting language like javascript can't do, since it only operates on the client's browser.

    Don't worry, they aren't too hard, it just takes a little bit of homework.

    For instance I could show you how to make people login WITHOUT a database (assuming there are a very limited amount of users) just using a cookie or session variable in ASP... and I'm quite sure any other server-side scripting language will do the same thing.

    Unfortunately client-side scripting isn't really cut out for this - but you might want to check out the "Encrypted Password Script" on www.javascriptkit.com

    By the way (George)... is javascriptkit.com still going to be there?! I'm assuming just the forum has moved?
    Last edited by whammy; 06-20-2002 at 02:14 AM.
    Former ASP Forum Moderator - I'm back!

    If you can teach yourself how to learn, you can learn anything. ;)


  •  

    Posting Permissions

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