// Source: https://www.quirksmode.org/js/cookies.html
-
-function setCookie(name,value)
+function setCookie(name, value)
{
var date = new Date();
date.setTime(date.getTime()+(183*24*60*60*1000)); //6 months
document.cookie = name+"="+value+expires+"; path=/";
}
-function getCookie(name) {
+function getCookie(name, defaut) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for (var i=0;i < ca.length;i++)
if (c.indexOf(nameEQ) == 0)
return c.substring(nameEQ.length,c.length);
}
- return null;
+ return defaut; //cookie not found
}
+// Random (enough) string for socket and game IDs
function getRandString()
{
- // Random enough (for socket and game IDs)
return (Date.now().toString(36) + Math.random().toString(36).substr(2, 7))
.toUpperCase();
}