Q:

how to read cookies in jquery?

I am creating a cookie with a key and value of an object using carhartl’s jQuery cookie plugin,In one of my method I call create cookie and right after that I call get cookie;but the read method doesn't work:
makeCookie methode:
function makeCookie(name,value){
    $.cookie(name,value);
}

readCookie method:
function readCookie(name){
    $.parseJSON($.cookie(name));
}

and calling these 2 methods:
makeCookie('chatPopups',popUps);
    var all=readCookie('chatPopups');
    alert(all);

popUps is a global javascript object;
The error I get is :
SyntaxError: JSON.parse: unexpected character at line 1 column 2 of the JSON data

can anybody help me?

A:

Solved the problem,changed makeCookie method to this:
function makeCookie(name,value){
    $.cookie(name,$.param(value),{ path: '/' });
}

and readCookie method to this:
function readCookie(name){
    var readCookie=$.cookie(name);
    readCookie = readCookie.split('&');
    if(readCookie.length != 0){
    for (i=0; i<readCookie.length; i++) {
        readCookie[i] = readCookie[i].split('=');
        popUps[readCookie[i][0]] = readCookie[i][1];
    }
    }
}

