I am working from this thread:
What is the shortest function for reading a cookie by name in JavaScript?
Which shows that a cookie can be read in JavaScript using the following code:
function read_cookie(key)
{
var result;
return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? (result[1]) : null;
}
I have a cookie which is set called "country" and its value is two letters, for example "AZ". I am wondering how one goes about reading the value of the cookie and putting it into a variable called cookie_country for example. This regexp is a little above me and I dont know where to start.