0

I am trying to set a cookie with ngx-cookie-service to be able to retrieve it later

The code is working fine when refreshing and the cookie is present in the chrome developer tools - Applications - cookies with an expiry date after a year .

when the browser is closed then opened , the cookie is not there when going to the application

My Code

 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'
           ); 
        
    }
  • I think it's better to ask the maintainers of the library in GitHub :https://github.com/stevermeister/ngx-cookie-service you will get better answers there – Rebai Ahmed Mar 01 '22 at 10:04

1 Answers1

0

It turned out to be one stupid missed point from my side . My chrome had the option " clear cookies and site data when you close all windows " activated in the security section .