jq cookie操作

jquery.cookie.js
下载:http://plugins.jquery.com/cookie/

$.cookie(‘the_cookie’, ‘the_value’); // 添加一个会话
$.cookie(‘the_cookie’, ‘the_value’, { expires: 7 }); //创建一个cookie并设置有效时间为 7天
var expiresDate= new Date();
expiresDate.setTime(expiresDate.getTime() + (120601000));//2h后过期
$.cookie(‘username’, res.data.username, { expires: expiresDate, path: ‘/’ });

$.cookie(‘the_cookie’, ‘the_value’, { expires: 7, path: ‘/’ }); //创建一个cookie并设置 cookie的有效路径
$.cookie(‘the_cookie’); //读取cookie
$.cookie(‘the_cookie’, null); //通过传递null作为cookie的值即可 //删除cookie
$.cookie(‘the_cookie’,‘the_value’,{
expires:7,
path:’/’,
domain:‘jquery.com’,
secure:true
})

expires:(Number|Date)有效期;设置一个整数时,单位是天;也可以设置一个日期对象作为Cookie的过期日期;
path:(String)创建该Cookie的页面路径;
domain:(String)创建该Cookie的页面域名;
secure:(Booblean)如果设为true,那么此Cookie的传输会要求一个安全协议,例如:HTTPS;

好消息CRMEB系统开源啦! 开源地址:http://github.crmeb.net/u/lsq
演示站后台:http://demo25.crmeb.net 账号:demo 密码:crmeb.com

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值