我试图使用原生NodeJS过期cookie,特别是针对Chrome浏览器。但是,我所放置的失效日期并不会导致cookie消失。
截至目前,这是我的代码:
cookie: Expires=Wed Mar 22 2017 02:14:52 GMT-0400 (EDT)
即使在后续请求之后,我最终也会像过期日期那样获得Cookie:
generateClearanceExcel(): void {
if (this.selectedIds.length > 0) {
var departureDate = prompt("Please enter departure date.", "");
if (departureDate !== null && departureDate !== "") {
this.generating = true;
this.clearanceService.generateClearanceExcel(this.selectedIds, departureDate).subscribe(
result => {
this.generating = false;
window.location.href = "clearance/downloadreport/?fileName=" + result.fileName;
if (result.success == true) {
this.clearanceService.deleteFile(result.fileName).subscribe();
if (result.infos.length > 0) {
this.alertService.info(result.infos);
}
}
else {
this.alertService.error(result.errors);
}
}
);
}
}
}
答案 0 :(得分:0)
试试这个,它可能适合你。
'Set-Cookie':'sesh=wakadoo; expires='+new Date(new Date().getTime()+86409000).toUTCString();
将 sesh = wakadoo 替换为您的变量。
答案 1 :(得分:0)