I am using ngx-cookie-service component but as soon as i close the browser the cookies disappears, maybe i have to set the expire parameter but i can\'t get it , below what
I've solved it like that
this.expiredDate = new Date();
this.expiredDate.setDate( this.expiredDate.getDate() + 7 );
//write
this.cookieService.set( 'key',JSON.stringify('value'), this.expiredDate);
//read
console.log(JSON.parse(this.cookieService.get( 'key'));
Remember to inject the cookieService
import { CookieService } from 'ngx-cookie-service';
constructor(private cookieService: CookieService) {}
Install
npm install angular2-cookie --save