javascriptangularcookiesangular-cookies

Add/Delete angular2 ng2-cookies to a path


How to add and delete ng2-cookies from a specific path?


Solution

  • To install this library, run:

    $ npm install ng2-cookies
    

    Usage:

    import { Cookie } from 'ng2-cookies/ng2-cookies';
    
    Cookie.set('cookieName', 'cookieValue', 10, '/path');
    
    let myCookie = Cookie.get('cookieName');
    
    let cookielist = Cookie.getAll('/path');
    
    Cookie.delete('cookieName', '/path');
    Cookie.deleteAll('/path');
    

    Try these in case the cookies set into your single domain is path dependent.