我正在尝试使用 ngx-cookie-service 设置一个 cookie,以便以后能够检索它
刷新时代码工作正常,并且 cookie 存在于 chrome 开发人员工具 - 应用程序 - cookie 中,有效期为一年。
当浏览器关闭然后打开时,进入应用程序时cookie不存在
我的代码
import {CookieService} from 'ngx-cookie-service';
setcookie(U:User)
{
let domain = "localhost";
let path = '/';
let secure = true;
let expiry = new Date();
expiry.setDate(expiry.getDate()+365);
this.cookieService.set(
'userCookie',
JSON.stringify(U)
,expiry,path,domain,secure,'None'
);
}