Modifs to send current live game
[vchess.git] / client / src / utils / cookie.js
1 // Source: https://www.quirksmode.org/js/cookies.html
2 export function setCookie(name, value)
3 {
4 var date = new Date();
5 date.setTime(date.getTime()+(183*24*60*60*1000)); //6 months
6 var expires = "; expires="+date.toGMTString();
7 document.cookie = name+"="+value+expires+"; path=/";
8 }
9
10 export function getCookie(name, defaut) {
11 var nameEQ = name + "=";
12 var ca = document.cookie.split(';');
13 for (var i=0;i < ca.length;i++)
14 {
15 var c = ca[i];
16 while (c.charAt(0)==' ')
17 c = c.substring(1,c.length);
18 if (c.indexOf(nameEQ) == 0)
19 return c.substring(nameEQ.length,c.length);
20 }
21 return defaut; //cookie not found
22 }