//Cookie取值
  function readCookie (name)
  {
    var cookieValue = "";
    var search = name + "=";
    if (document.cookie.length > 0)
    {
      offset = document.cookie.indexOf (search);
      if (offset != -1)
      {
        offset += search.length;
        end = document.cookie.indexOf (";", offset);
          if (end == -1)
             end = document.cookie.length;
             cookieValue = unescape (document.cookie.substring (offset, end))
      }
    }
        return cookieValue;
  }
  //Cookie设置值
  function writeCookie (name, value, hours)
  {
  var expire = "";
  if (hours != null)
  {
  expire = new Date ((new Date ()).getTime () + hours * 3600000);
  expire = "; expires=" + expire.toGMTString ();
  }
  document.cookie = name + "=" + escape (value) + expire;
  }
//调用设置
writeCookie ("myCookie", "my name", 24);
//调用取值
alert (readCookie ("myCookie"));
</script>

最新文章

  1. javascript仿天猫加入购物车动画效果
  2. git/github 使用
  3. hdu1251
  4. wpf 绑定ObservableCollection 的Count属性
  5. nodejs对静态文件目录的处理
  6. Spark RDD概念学习系列之Spark Hash Shuffle内幕彻底解密(二十)
  7. 新建PCH文件以及常用宏定义
  8. 自定义JsonResult处理JSON序列化DateTime类型数据(Ext4.2+ASP.NET MVC 4)
  9. vscode编写插件
  10. 转发:招聘一个靠谱的 iOS
  11. HDU 5616 Jam&#39;s balance
  12. 选择Web框架的20条标准
  13. 基础Gan代码解析
  14. VS开发入门一:VS常用快捷键大全,工欲善其事必先利其器 只看标红的吧
  15. 为什么用freemarker视图?
  16. win10 教育版本变专业版本
  17. linux中DHCP服务配置文件/etc/dhcpd.conf详细说明
  18. [Windows Azure] Managing SQL Database using SQL Server Management Studio
  19. Jenkins基础复习
  20. bzoj 1261 区间DP

热门文章

  1. 洛谷——————ISBN号码
  2. JSAJAX请求
  3. EVE上传Dynamips、IOL和QEMU镜像
  4. 简单的jquery Ajax进行登录!
  5. ES-windows版本设置远程访问
  6. redhat 7.6安装kvm
  7. Maven中配置jdk的版本
  8. node环境下:node_modules里面的文件
  9. SQLServer亿万级数据优化
  10. 路由器安全-FPM