Results 1 to 4 of 4

Thread: New user cookie - Do or do not?

  1. #1
    Join Date
    Jul 2007
    Location
    California
    Posts
    177
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default New user cookie - Do or do not?

    I came upon a script that uses a cookie to tell if someone is new to my site or not. If they are new, it will redirect to an intro page. I like the idea of being able to have a direct message without letting them be distracted by the menus, or the slideshow. Basically I get their attention for 10 seconds, until they click the enter site button... I will paste the script at the end of the message for reference.

    My question is this... Will this cause problems if the user has cookies set to off? Will it just constantly look for the cookie, not see it, and always send them back to the intro page? If that is the case, that would be super annoying and I wouldn't use the script. I'm hoping that if they have cookies off, it wouldn't redirect them, and would just let them sit on my home page.


    Thank you!

    Script:

    Now here is the script. Just copy everything into your <head></head> tag. what you need to change is REDIRECTING LOCATION and COOKIE NAME (name this something unique that no one else will have)
    <SCRIPT LANGUAGE="JavaScript">
    <!-- Hide from old browsers


    var caution = false

    function setCookie(name, value, expires, path, domain, secure) {
    var curCookie = name + "=" + escape(value) +
    ((expires) ? "; expires=" + expires.toGMTString() : "") +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    ((secure) ? "; secure" : "")
    if (!caution || (name + "=" + escape(value)).length <= 4000)
    document.cookie = curCookie
    else
    if (confirm("Cookie exceeds 4KB and will be cut!"))
    document.cookie = curCookie
    }

    function getCookie(name) {
    var prefix = name + "="
    var cookieStartIndex = document.cookie.indexOf(prefix)
    if (cookieStartIndex == -1)
    return null
    var cookieEndIndex = document.cookie.indexOf(";", cookieStartIndex + prefix.length)
    if (cookieEndIndex == -1)
    cookieEndIndex = document.cookie.length
    return unescape(document.cookie.substring(cookieStartIndex + prefix.length, cookieEndIndex))
    }

    function deleteCookie(name, path, domain) {
    if (getCookie(name)) {
    document.cookie = name + "=" +
    ((path) ? "; path=" + path : "") +
    ((domain) ? "; domain=" + domain : "") +
    "; expires=Thu, 01-Jan-70 00:00:01 GMT"
    }
    }

    function fixDate(date) {
    var base = new Date(0)
    var skew = base.getTime()
    if (skew > 0)
    date.setTime(date.getTime() - skew)
    }

    var now = new Date()
    fixDate(now)
    now.setTime(now.getTime() + 365 * 24 * 60 * 60 * 1000)
    var visits = getCookie("newtousejeff")
    if (!visits)
    location = "http://www.usejeff.com/newuser.html"
    setCookie("newtousejeff", visits, now)


    // -->
    </SCRIPT>

    if you want the user to be able to see the entry page again, then they need to delete the cookie. Call this function from a link or a button. Using my example, it would look like this.
    <form><input type="button" onClick="deleteCookie('COOKIE NAME'); location.reload();" value="Delete The Cookie"></form>

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    My question is this... Will this cause problems if the user has cookies set to off? Will it just constantly look for the cookie, not see it, and always send them back to the intro page? If that is the case, that would be super annoying and I wouldn't use the script. I'm hoping that if they have cookies off, it wouldn't redirect them, and would just let them sit on my home page.
    It is the case, and yes, it would be annoying
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jul 2007
    Location
    California
    Posts
    177
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default

    Bummer...really looked like a cool idea to deliver the key message. Guess I'll have to rely on my keen eye and inherent intuitive design characteristics to be sure they get it.... er wait., who am I kidding!.. I can't draw, and I hang my paintings sideways. I guess instead I will go with the roll the dice theory and hope they get the message I'm trying to imply

    Thanks Twey

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Intro pages are quite common, and not too bothersome if you remember to include a "skip intro" link somewhere easily accessible from the top. I'd think that combined with the cookie would be sufficient to justify its use.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

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
  •