jquery設置cookie過期時間與檢查cookies是否可用
讓cookies在x分鐘後過期
var date = new date();
datesettime(date gettime() + (x * * ));
$cookie(‘example ‘foo { expires: date });
檢查cookies是否可用
$(document)ready(function() {var dt = new date();dt setseconds(dt getseconds() + );document cookie = “cookietest= ; expires=” + dt togmtstring();var cookiesenabled = document cookie indexof(“cookietest=”) != ;if(!cookiesenabled){//cookies不能用…… }});
From:http://tw.wingwit.com/Article/program/Java/hx/201404/30484.html