Get cookies - Node.js Environment

Node.js examples for Environment:Cookie

Description

Get cookies

Demo Code

function getCookie(name) {
    var prefix = name + "=" 
    var start = document.cookie.indexOf(prefix) 

    if (start==-1) {
        return null;
    }/*from   w  w w .  ja va 2 s . c  o  m*/
    
    var end = document.cookie.indexOf(";", start+prefix.length) 
    if (end==-1) {
        end=document.cookie.length;
    }

    var value=document.cookie.substring(start+prefix.length, end) 
    return unescape(value);
}

Related Tutorials