日期:2014-05-16  浏览次数:20267 次

使cookie失效的js代码

date = new Date();
date.setTime(date.getTime() + ?(0.5 * 60 * 60 * 1000));//单位为毫秒
var expires = '; expires=' + ?date.toUTCString();
document.cookie = ['key', '=', ‘value’, expires, '; path=/', '', ''].join('');

?

?

其中key 为 cookie 的键名 ,value 是cookie的值内容,

cookie在firefox中很容易看到,工具->选项->试用自定义历史记录设置->显示cookies,在弹出的窗口中就可以很容易看到cookie的信息了,包括名称、内容、主机、路径、发送条件和过期时间。

?

在Firefox中可以安装firebug , 在firebug中粘贴js 脚本运行即可。

?

在ie8中可以运用开发人员工具,粘贴js脚本运行即可。