angularjs应用程序到期时未删除Javascript cookie
我需要在AngularJS应用程序控制器中存储一个有效期为4分钟的cookie 我的代码:angularjs应用程序到期时未删除Javascript cookie,javascript,angularjs,cookies,Javascript,Angularjs,Cookies,我需要在AngularJS应用程序控制器中存储一个有效期为4分钟的cookie 我的代码: var d=新日期(); d、 设置时间(d.getTime()+(4*60*1000)); var expDate=“expires=“+d.toutString(); document.cookie=“testVal=“+data+”expires=“+expDate+”;this.hostName;path=/”; 过期4分钟后,cookie应自行删除,但不会被删除并继续保留 但当我通过浏览器控制
var d=新日期();
d、 设置时间(d.getTime()+(4*60*1000));
var expDate=“expires=“+d.toutString();
document.cookie=“testVal=“+data+”expires=“+expDate+”;this.hostName;path=/”;
过期4分钟后,cookie应自行删除,但不会被删除并继续保留
但当我通过浏览器控制台使用同一行代码设置同一个cookie时,它确实会在到期时被删除
浏览器:IE v11
我在写Cookie的时候遗漏了什么吗?感谢您的帮助或建议。
constcreatecookie=(名称、值、分钟)=>{
const date=新日期();
date.setTime(date.getTime()+(分钟*60*1000));
const expires=minutes?;expires=“+date.togmString():”;
document.cookie=`${name}=${value}${expires};path=/`;
}
createCookie(“CookieName”、“Cookievalue”,5)
数据变量分配给什么?data
是cookie的值,testVal
是cookie的名称。