jquery.cookie.js是一個基於jquery的插件javascript
因此要加上兩條引用:java
使用前要先導入jquery.jsjquery
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>ajax
而後再導入jquery.cookie.js,可使用google和百度搜索下再下載api
<script type="text/javascript" src="http://yxb.qq.com/js/jquery.cookie.js"></script>cookie
- $.cookie('the_cookie'); // 得到cookie
- $.cookie('the_cookie', 'the_value'); // 設置cookie
- $.cookie('the_cookie', 'the_value', { expires: 7 }); //設置帶時間的cookie天
- $.cookie('the_cookie', '', { expires: -1 }); // 刪除
- $.cookie('the_cookie', null); // 刪除 cookie
- $.cookie('the_cookie', 'the_value', {expires: 7, path: '/', domain: 'jquery.com', secure: true});//新建一個cookie 包括有效期 路徑 域名等