JS设置cookie,删除cookie(引) js设置cookie有很多种方法. 第一种:(这个是w3c官网的代码) <script> //设置cookie function setCookie(cname, cvalue, exdays) { var d = new Date(); d.setTime(d.getTime() + (exdays*24*60*60*1000)); var expires = "expires="+d.toUTCString(); docum
function addCookie(objName,objValue,objHours){//添加cookie var str = objName + "=" + escape(objValue); if(objHours > 0){//为0时不设定过期时间,浏览器关闭时cookie自动消失 var date = new Date(); var ms = objHours*3600*1000; date.setTime(date.getTime() + ms); str +=
(function(){ var name = "whr";//cookie的名字 var value = "whr1";//cookie的值 var aaa = new Date((new Date()).setTime((new Date()).getTime() + (24 * 60 * 60 * 1000))).toUTCString() document.cookie = name+'='+value+';expires='+aaa+';path=/;';