JAVASCRIPT   49
login cookies
Guest on 6th February 2023 02:23:28 AM


  1. function getCookie(cookieName){
  2.                 var search = cookieName + "=";
  3.                 var cookie = document.cookie;
  4.  
  5.                 if( cookie.length > 0 ){
  6.                 startIndex = cookie.indexOf( cookieName );
  7.  
  8.                         if( startIndex != -1 ){
  9.                                 startIndex += cookieName.length;
  10.                                 endIndex = cookie.indexOf( ";", startIndex );
  11.                
  12.                                 if( endIndex == -1) endIndex = cookie.length;
  13.                                 return unescape( cookie.substring( startIndex + 1, endIndex ) );
  14.                         }else{
  15.                                 return false;
  16.                         }
  17.                 }else{
  18.                         return false;
  19.                 }
  20.         }
  21.  
  22.         function setCookie(cookieName, cookieValue, expireDate){
  23.                 var today = new Date();
  24.                 today.setDate( today.getDate() + parseInt( expireDate ) );
  25.                 document.cookie = cookieName + "=" + escape( cookieValue ) + "; path=/; expires=" + today.toGMTString() + ";";
  26.         }
  27.  
  28.         function readCookie(){
  29.                 if(getCookie("idCook")!=false){
  30.                         $("input:checkbox[id='save']").attr("checked", true);
  31.                         $("input:checkbox[id='save']").parent().addClass("checked");
  32.                         $("#usrEmail").val(getCookie("idCook"));
  33.                         $("#usrPassword").focus();
  34.                 }else{
  35.                         $("#usrEmail").focus();
  36.                 }
  37.         }
  38.  
  39.         function deleteCookie(cookieName){
  40.                 var expireDate = new Date();
  41.                 expireDate.setDate( expireDate.getDate() - 1 );
  42.                 document.cookie = cookieName + "= " + "; expires=" + expireDate.toGMTString() + "; path=/";
  43.         }

Raw Paste

Login or Register to edit or fork this paste. It's free.