Retrieve jQuery Cookie value

This worked for me

function getCookieValue(cname) { // cname is nothing but the cookie value which 
                                 //contains the value
                    var name = cname + "=";
                      var decodedCookie = decodeURIComponent(document.cookie);
                      var ca = decodedCookie.split(';');
                      for(var i = 0; i <ca.length; i++) {
                        var c = ca[i];
                        while (c.charAt(0) == ' ') {
                          c = c.substring(1);
                        }
                        if (c.indexOf(name) == 0) {
                          return c.substring(name.length, c.length);
                        }
                      }
                      return "";
                    }

It's just var foo = $.cookie("foo").

There's no need for a .val() call as you're not accessing the value of a DOM element.