zoukankan      html  css  js  c++  java
  • Cookie之获设删

     1 //设置COOKIE值
     2 function setCookie(sName,sValue,oExpires,sPath,sDomain,bSecure)
     3 {
     4     var sCookie = sName + "=" + encodeURIComponent(sValue);
     5 
     6     if(oExpires) { sCookie += "; expires=" + oExpires.toString(); }
     7 
     8     if(sPath) { sCookie += "; path=" + sPath; }
     9 
    10     if(sDomain) { sCookie += "; domain=" + sDomain; }
    11 
    12     if(bSecure) { sCookie += "; secure"; }
    13 
    14     document.cookie = sCookie;
    15 }
    16 
    17 //获取COOKIE值
    18 function getCookie(sName)
    19 {
    20     var sRE = "(?:; )?" + sName + "=([^;]*);?";
    21     var oRE = new RegExp(sRE);
    22 
    23     if(oRE.test(document.cookie)) { return decodeURIComponent(RegExp["$1"]); }
    24     else { return null; }
    25 }
    26 
    27 //删除COOKIE值
    28 function deleteCookie(sName,sPath,sDomain)
    29 {
    30     setCookie(sName,"",new Date(0),sPath,sDomain);
    31 }
  • 相关阅读:
    15-数组concat()方法和push比较
    06-使用云储存上传工具
    05-云函数/云数据库的增删改查
    错题1
    c++链表
    8817
    8816
    1177
    1355
    c++期末考
  • 原文地址:https://www.cnblogs.com/xiaoleyuan/p/7452120.html
Copyright © 2011-2022 走看看