How to clear cookies in angular.js

user2998788 picture user2998788 · Jan 8, 2014 · Viewed 62.9k times · Source

Currently am using angulajs app.

I want to store some values in cookie. So i used angular-cookies-min script for add some values to cookies

I have used this below code for save values to cookie.

 $cookieStore.put("userInfo", userInfo);//userInfo is a array with some values. 

Now I want to clear the cookie? How can i do it?

Answer

michael picture michael · Jan 8, 2014

Try this code for delete cookie

$cookieStore.remove("userInfo");

EDIT: Since v1.4 $cookieStore has been deprecated (see docs), so from that version on you should use:

$cookies.remove("userInfo");