Cookie操作是我们在Web开发中经常会用到的功能,以往我们一般是通过javascript实现的,但用javascript实现过于复杂,所以不如使用jquery控制cokkie。下面这款jquery插件是专门用来进行cookie操作的,包括cookie的添加、清除、读取……
$.cookie(‘the_cookie’); // 获得cookie
$.cookie(‘the_cookie’, ‘the_value’); // 设置cookie
$.cookie(‘the_cookie’, ‘the_value’, { expires: 7 }); //设置带时间的cookie,同时设置过期时间(expires属性)为7天:
$.cookie(‘the_cookie’, ‘the_value’, { expires: 7, path: ‘/’, domain: ‘javachen.com’, secure: true }); //设置带时间的cookie,同时设置过期时间(expires属性)为7天:,同时设置cookie的path属性为”javachen.com/”
$.cookie(‘the_cookie’, ”, { expires: -1 }); // 删除
$.cookie(‘the_cookie’, null); // 删除 cookie
下载地址: http://plugins.jquery.com/files/jquery.cookie.js.txt
继续阅读…
Recent Comments