home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 201 / DPCS1104.ISO / Full / QuickBooks / QBooks / data1.cab / Pages_Questions / EmpSolutionscookies.js < prev    next >
Encoding:
JavaScript  |  2004-05-21  |  1.4 KB  |  44 lines

  1. // COOKIE FUNCTIONS
  2.  
  3. // setCookie (name, value)    - sets a name value pair in the cookie
  4. // getCookie (name)           - returns the value associated with the name
  5. // deleteCookie (name)        - destroys the name value pair in the cookie
  6.  
  7. function setPermanentCookie (name, value)
  8. { // creates temporary cookies, if you make a permanent cookie choose date way in future
  9.   document.cookie = escape(name) + "=" + escape(value) + ";path=/;expires=Fri, 2-Jan-2025 00:00:00 GMT;"; 
  10. } // End Function
  11.  
  12.  
  13. function getCookie (name) {
  14.   if (document.cookie == '') {
  15.     return false;
  16.     }
  17.     else {
  18.         var firstChar, lastChar;
  19.         var allCookies = document.cookie;
  20.         firstChar = allCookies.indexOf(name);
  21.         var theSpecifiedCookie = firstChar + name.length;
  22.         if ((firstChar != -1) && (allCookies.charAt(theSpecifiedCookie) == '=')) {
  23.           firstChar += name.length + 1;
  24.           lastChar = allCookies.indexOf(';' , firstChar);
  25.           if (lastChar == -1) lastChar = allCookies.length; {
  26.             return unescape(allCookies.substring(firstChar, lastChar));
  27.               }
  28.           }
  29.           else {
  30.               return false;
  31.               }
  32.           }
  33. } // End Function
  34.  
  35.  
  36. function deleteCookie(name)
  37. {
  38.   var theValue = getCookie(name);
  39.    if(theValue)
  40.    {
  41.      //alert("deleting " + name)
  42.       document.cookie = name + '="";path=/;expires=Fri, 13-Apr-1970 00:00:00 GMT;';
  43.    }
  44. } // End Function