添加/删除angular2 ng2-cookies到路径

时间:2017-03-21 08:15:00

标签: javascript angular cookies angular-cookies

如何从特定路径添加和删除ng2-cookies

1 个答案:

答案 0 :(得分:2)

要安装此库,请运行:

$ npm install ng2-cookies

用法:

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');

如果设置到您的单个域中的Cookie与路径有关,请尝试使用这些。