zoukankan      html  css  js  c++  java
  • js cookie

     js操作cookie的问题。

    做个标记

    /**//************************************************************************

    |    函数名称: setCookie                                                |
    |    函数功能: 设置cookie函数                                            |
    |    入口参数: name:cookie名称;value:cookie 值                        |
    |    维护记录: RainBow(创建)                                            |
    |    版权所有: (C) 2006-2007                    |
    |    编写时间: 2007年9月13 日 21:00                                        |
    *************************************************************************/
    function setCookie(name, value)
    {
        var argv = setCookie.arguments;
        var argc = setCookie.arguments.length;
        var expires = (argc > 2) ? argv[2] : null;
        if(expires!=null)
        {
            var LargeExpDate = new Date ();
            LargeExpDate.setTime(LargeExpDate.getTime() + (expires*1000*3600*24));         
        }
        document.cookie = name + "=" + escape (value)+((expires == null) ? "" : ("; expires=" +LargeExpDate.toGMTString()))+"; path=" + "/";
    }
    /**//************************************************************************
    |    函数名称: getCookie                                                |
    |    函数功能: 读取cookie函数                                            |
    |    入口参数: Name:cookie名称                                            |
    |    维护记录: RainBow(创建)                                            |
    |    版权所有: (C) 2006-2007                    |
    |    编写时间: 2007年9月13 日 21:02                                        |
    *************************************************************************/
    function getCookie(Name)
    {
        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
                return unescape(document.cookie.substring(offset, end))
            }
            else return "";
        }
    }

    /**//************************************************************************
    |    函数名称: deleteCookie                                            |
    |    函数功能: 删除cookie函数                                            |
    |    入口参数: Name:cookie名称                                        |
    |    维护记录: RainBow(创建)                                        |
    |    版权所有: (C) 2006-2007                 |
    |    编写时间: 2007年9月15 日 18:10                                    |
    *************************************************************************/    
    function delCookie(name)
    {
         var expdate = new Date();
         expdate.setTime(expdate.getTime() - (86400 * 1000 * 1));
         setCookie(name, "", expdate);
    }
  • 相关阅读:
    跨平台GUIQt windows 开发环境安装配置(Eclipse CDT+ MinGW+QT) (转载)
    跨平台GUIQt windows 开发环境安装配置(VS2005+QT+IntegrationPlugin)(转载)
    跨平台GUIQt ACER Aspire on Linux 开发环境安装配置(QT + GCC ) (原创)
    移动视频监控(2)原型开发Symbian客户端进展。
    编程语言大串联(1)C#,Java,C++
    优化页面上的sql
    一个段错误调试
    查询数据库空间
    shell 批量替换多个文件中字符串
    用户组相关
  • 原文地址:https://www.cnblogs.com/youliny/p/1778329.html
Copyright © 2011-2022 走看看