Google News
logo
Angular - Interview Questions
In Angular, describe how will you set, get and clear cookies ?
For using cookies in Angular, you need to include a  module called ngCookies angular-cookies.js.
 
To set Cookies – For setting the cookies in a key-value format ‘put’ method is used.
 
cookie.set('nameOfCookie',"cookieValue");

To get Cookies – For retrieving the cookies ‘get’ method is used.
 
cookie.get(‘nameOfCookie’);

To clear Cookies – For removing cookies ‘remove’ method is used.
 
cookie.delete(‘nameOfCookie’);
Advertisement