Web Analytics Made Easy -
StatCounter Cookie Help - Log-on vs Registration - CodingForum


No announcement yet.

Cookie Help - Log-on vs Registration

  • Filter
  • Time
  • Show
Clear All
new 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()
    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.',"");

    Please help

  • #2
    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; Jun 19, 2002, 09:14 PM.
    Former ASP Forum Moderator - I'm back!

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