Advertisement
Claof

Simplified auto-saving variable - JavaScript

Dec 23rd, 2015
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var AUTO_SAVING_VARIABLE=0;
  2. if (document.cookie) {
  3. SplitCookie = document.cookie.split('=');
  4. AUTO_SAVING_VARIABLE = SplitCookie[1];
  5. } else {
  6. document.cookie = 'AUTO_SAVING_COOKIE=VALUE;expires=Fri, 31 Dec 9999 00:00:00 UCT;path=/';
  7. window.location.href='';
  8. }
  9. setInterval("document.cookie = 'AUTO_SAVING_COOKIE='+AUTO_SAVING_VARIABLE+';expires=Fri, 31 Dec 9999 00:00:00 UCT;path=/'",0);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement