jquery 獲取cookie值
cookie有四個不同的屬性:
名稱,內容,域,路徑
程式碼如下 | 複製程式碼 |
|
使用:
程式碼如下 | 複製程式碼 |
$.cookie("currentMenuID", menuID); |
時 未指定域和路徑。
所有當域和路徑不同時會產生不同的cookie
程式碼如下 | 複製程式碼 |
$.cookie("currentMenuID"); |
取值時會產生問題。
故:
程式碼如下 | 複製程式碼 |
$.cookie("currentMenuID", "menuID", { path: "/"}); |
進行覆蓋。同域下同一個cookieID對應一個值。
下面我們來看個例項
關於cookie的path設定需要注意,如果不設定path:'/'的話,path則會根據目錄自動設定[如:http://www.xxx.com/user/,path會被設定為 '/user']
程式碼如下 | 複製程式碼 |
$.extend({ |
Jquery操作Cookie記錄使用者查詢過資訊
http://www.php100.com/wy/js-ajax/40554.htm