zoukankan      html  css  js  c++  java
  • js cookie

    cookie 就是js里面的文件操作 地位是很重要的
    ie 和 firefox存储cookie的位置不同 所以会有两个浏览器一个登录了 另一个不能登录的现象
    cookie文件时不能手动修改的
    两个域名不能共享cookie
    cookie还有个过期时间

    对于一个文件来讲 只要能够存取就够了


    function getCookie(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;
    }

    function setCookie(cookieName,cookieValue,DayValue)
    {
    var expire = "";
    var day_value=1;
    if(DayValue!=null)
    {
    day_value=DayValue;
    }
    expire = new Date((new Date()).getTime() + day_value * 86400000);
    expire = "; expires=" + expire.toGMTString();
    document.cookie = cookieName + "=" + escape(cookieValue) +";path=/"+ expire;
    }

    function delCookie(cookieName)
    {
    var expire = "";
    expire = new Date((new Date()).getTime() - 1 );
    expire = "; expires=" + expire.toGMTString();
    document.cookie = cookieName + "=" + escape("") +";path=/"+ expire;
    /*path=/*/
    }
  • 相关阅读:
    分页功能
    四个内置对象的作用范围
    include和application
    jsp中的session
    IDC机房的相关常识
    使用dm-cache组合SSD与HDD实现高性价比存储
    负载均衡基本原理与lvs
    秒级别执行脚本的方法
    Tomcat调优
    Nginx调优
  • 原文地址:https://www.cnblogs.com/frog2008/p/2349801.html
Copyright © 2011-2022 走看看