views:

211

answers:

1

How to find the cookie blocked using java script code

+4  A: 

Write a cookie and then read it...

for example:

    function readCookie(cname) {
        a = trim(document.cookie);
        res = '';
        while(a != '') {
            cookiename = a.substring(0,a.search('='));
            cookiewert = a.substring(a.search('=')+1,a.search(';'));
            if(cookiewert == '' || a.search(';')==-1) {
                cookiewert = a.substring(a.search('=')+1,a.length);
            } else {
                cookiewert = a.substring(a.search('=')+1,a.search(';'));
            }

        if(cname == trim(cookiename)){
            res = cookiewert;
            return (res);
        }
        i = a.search(';')+1;
        if(i == 0){i = a.length}
        a = a.substring(i,a.length);
     }
     return(res)
    }

    function checkSessionCookie() {
     //write cookie
     document.cookie = 'sessioncookieallowed=true;';
     var check = readCookie('sessioncookieallowed');
    }

call function checkSessionCookie();

Thollsten