home *** CD-ROM | disk | FTP | other *** search
/ The X-Files: Unrestricted Access / XFUA1.iso / The X-Files Unrestricted Access / data1.cab / Browser / browser / cookies.js < prev    next >
Encoding:
Text File  |  1998-02-17  |  1.1 KB  |  39 lines

  1. function getCookieVal (offset) {
  2.   var endstr = document.cookie.indexOf (";", offset);
  3.   if (endstr == -1)
  4.     endstr = document.cookie.length;
  5.   return unescape(document.cookie.substring(offset, endstr));
  6. }
  7.  
  8. function GetCookie (name) {
  9.   var arg = name + "=";
  10.   var alen = arg.length;
  11.   var clen = document.cookie.length;
  12.   var i = 0;
  13.   while (i < clen) {
  14.     var j = i + alen;
  15.     if (document.cookie.substring(i, j) == arg)
  16.       return getCookieVal (j);
  17.     i = document.cookie.indexOf(" ", i) + 1;
  18.     if (i == 0) break; 
  19.   }
  20.   return null;
  21. }
  22.  
  23. function SetCookie (name,value,expires,path,domain,secure) {
  24.   document.cookie = name + "=" + escape (value) +
  25.     ((expires) ? "; expires=" + expires.toGMTString() : "") +
  26.     ((path) ? "; path=" + path : "") +
  27.     ((domain) ? "; domain=" + domain : "") +
  28.     ((secure) ? "; secure" : "");
  29. }
  30.  
  31. function DeleteCookie (name,path,domain) {
  32.   if (GetCookie(name)) {
  33.     document.cookie = name + "=" +
  34.       ((path) ? "; path=" + path : "") +
  35.       ((domain) ? "; domain=" + domain : "") +
  36.       "; expires=Thu, 01-Jan-70 00:00:01 GMT";
  37.   }
  38. }
  39.