Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

setCookie function

By: a guest on Dec 15th, 2011  |  syntax: JavaScript  |  size: 0.45 KB  |  views: 153  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. function setCookie(cookieName, value, daysToExpire, path, domain, secure) {
  2.         var expiryDate;
  3.  
  4.         if (daysToExpire) {
  5.                 expiryDate = new Date();
  6.                 expiryDate.setTime(expiryDate.getTime() + (daysToExpire * 8.64e7));
  7.         }
  8.  
  9.         document.cookie = cookieName + '=' + (value.toString()) +
  10.         (daysToExpire ? ';expires=' + expiryDate.toGMTString() : '') +
  11.         ';path=' + (path ? path : '/') +
  12.         (domain ? ';domain=' + domain : '') +
  13.         (secure ? ';secure' : '');
  14. };