js设置cookie过期及清除浏览器对应名称的cookie

时间:2013-10-24    点击:86   
复制代码 代码如下:

function ClearCookie() {
var expires = new Date();
expires.setTime(expires.getTime() - 1000); //当前时间减去一秒,相当于立即过期(可以增减)
document.cookie = "appCode='222''';path=/;expires=" + expires.toGMTString() + ""; //expires是对应过期时间的设置,不设这个值,cookie默认在关闭浏览器时失效
document.cookie = "roleID='333''';path=/;expires=" + expires.toGMTString() + "";
document.cookie = "parentMenuID='000''';path=/;expires=" + expires.toGMTString() + "";
document.cookie = "currentMenuName='哈哈''';path=/;expires=" + expires.toGMTString() + "";
}

path=/;表示cookie存放的位置是浏览器根目录

上述方法导致appCode,roleID,parentMenuID,currentMenuName4个cookie失效
javaScript arguments 对象使用介绍
通过length属性判断jquery对象是否存在
js 使FORM表单的所有元素不可编辑的示例代码
javascript中负数算术右移、逻辑右移的奥秘探索
jquery快捷动态绑定键盘事件的操作函数代码
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved