December 2013
Intermediate to advanced
384 pages
9h 54m
English
function getCookie(name) { var cArr = document.cookie.split(';'); for(var i=0;i < cArr.length;i++) { var cookie = cArr[i].split("=",2); cookie[0] = cookie[0].replace(/^\s+/,""); if (cookie[0] == name){ return cookie; } } }
To get the value of the cookie, split the document.cookie value using the ; character, and then iterate through the resulting array until you find the name you are looking for.
Read now
Unlock full access