1//You can call the function getCookie with the name of the cookie you want, then check to see if it is = null.
2
3function getCookie(name) {
4 var dc = document.cookie;
5 var prefix = name + "=";
6 var begin = dc.indexOf("; " + prefix);
7 if (begin == -1) {
8 begin = dc.indexOf(prefix);
9 if (begin != 0) return null;
10 }
11 else
12 {
13 begin += 2;
14 var end = document.cookie.indexOf(";", begin);
15 if (end == -1) {
16 end = dc.length;
17 }
18 }
19 // because unescape has been deprecated, replaced with decodeURI
20 //return unescape(dc.substring(begin + prefix.length, end));
21 return decodeURI(dc.substring(begin + prefix.length, end));
22}
23
24function doSomething() {
25 var myCookie = getCookie("MyCookie");
26
27 if (myCookie == null) {
28 // do cookie doesn't exist stuff;
29 }
30 else {
31 // do cookie exists stuff
32 }
33}