使用前要先下載並引入:jquery.cookie.js
https://github.com/carhartl/jquery-cookie
 

//設定 example 為 foo
$.cookie("example", "foo");

//設定 example 為 foo 且存活7天
$.cookie("example", "foo", { expires: 7 });

//設定 example 為 foo cookie 存活7天 且cooke path為 /admin
$.cookie("example", "foo", { path: '/admin', expires: 7 });

//取得example的值
$.cookie("example");

//刪除example
$.cookie("example", null)

When you save your cookies, set path to "/". Cookie will be available on all pages
$
.cookie('artname','value',{ path:'/'});
* cookie變數,想在不同頁面之間的傳遞,記得加上path變數!!!

arrow
arrow

    cabuchi 發表在 痞客邦 留言(0) 人氣()