好记性不如烂笔头。

jquery操作cookie

$.cookie('the_cookie'); // 读取 cookie 
$.cookie('the_cookie', 'the_value'); // 存储 cookie 
$.cookie('the_cookie', 'the_value', { expires: 7 }); // 存储一个带7天期限的 cookie 
$.cookie('the_cookie', '', { expires: -1 }); // 删除 cookie $(function(){
var COOKIE_NAME = 'test_cookie';
//设置cookie,通过时间间隔
$('a').eq(0).click(function() {
$.cookie(COOKIE_NAME, 'test', { path: '/', expires: 1 });
return false;
});
// 设置cookie,到期时间
$('a').eq(1).click(function() {
var date = new Date();
date.setTime(date.getTime() + (1 * 24 * 60 * 60 * 1000));
$.cookie(COOKIE_NAME, 'test', { path: '/', expires: date });
return false;
});
// 获取 cookie
$('a').eq(2).click(function() {
alert($.cookie(COOKIE_NAME));
return false;
});
// 删除cookie
$('a').eq(3).click(function() {
$.cookie(COOKIE_NAME, null, { path: '/' });
return false;
});
});