There are a lot of topics regarding this function, nonetheless I can\'t seem to get it working. I\'ve googled on this specific case and a bunch of links let me here, but strangl
If you don't strictly need to use cookies, using the newer HTML5 Web Storage (specifically the sessionStorage object in this case) is a lot easier and better than storing in a cookie:
http://www.w3schools.com/html/html5_webstorage.asp
Browser support is pretty full:
http://caniuse.com/#search=sessionstorage