Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 如何使用“ngx cookie服务”设置cookie过期日期`_Angular_Angular5 - Fatal编程技术网

Angular 如何使用“ngx cookie服务”设置cookie过期日期`

Angular 如何使用“ngx cookie服务”设置cookie过期日期`,angular,angular5,Angular,Angular5,我正在为我的angular5应用程序使用ngx cookie服务。有人能帮我指明设定过期日期的方法吗 我试着这样: setCookies($event){ this.cookieService.set( 'retailAppCookies', "true", 30 ); this.cookieService.set( 'expires', '2030-07-19' ); } 但这不管用。有人帮我吗?您不能在ngx cookie服务中添加日期您必须添加以下

我正在为我的angular5应用程序使用
ngx cookie服务
。有人能帮我指明设定过期日期的方法吗

我试着这样:

setCookies($event){
        this.cookieService.set( 'retailAppCookies', "true", 30 );
        this.cookieService.set( 'expires', '2030-07-19' );
    }

但这不管用。有人帮我吗?

您不能在ngx cookie服务中添加日期您必须添加以下天数

 this.cookieService.set('CookieName', 'Cookie Value', 5);

这将在5天后过期

这篇文章是否解决了同样的问题?我想答案可以帮助你。