Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

detecting a Cookie in HTML

HTML innerHTML

  • Please log in to reply
No replies to this topic

#1 code2learn

code2learn

    CC Lurker

  • Just Joined
  • Pip
  • 9 posts

Posted 01 January 2011 - 08:39 AM

Here is a piece of code that can help people detect cookies. Cookies play an important part in the website.

*****************#####*****************
JS Code:
window.onload = showCookies;

function showCookies() {
    var outMsg = "";

    if (document.cookie == "") {
        outMsg = "There are no cookies here";
    }
    else {
        var thisCookie = document.cookie.split("; ");
        for (var i=0; i<thisCookie.length; i++) {
            outMsg += "Cookie name is '" + thisCookie[i].split("=")[0];
            outMsg += "', and the value is '" + thisCookie[i].split("=")[1] + "'<br />";
        }
    }
    document.getElementById("ELEMENT ID").innerHTML = outMsg;
}

*****************#####*****************

Edited by Roger, 01 January 2011 - 06:05 PM.
removed links

  • 0





Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download