I want to see if a cookie has been set in Angular, and if it doesn't find a cookie, it will create a new one.
Right now I'm using this:
if ($cookies.get('storedLCookie').length != 0) {
$cookies.put('storedLCookie','Oatmeal');
}
It doesn't seem to be working, though. Is there another way to test if a cookie is set in Angular?
you can simply do this to check it:
var favoriteCookie = $cookies.get('cookieval');
if ( favoriteCookie ) {
//exists
} else {
//not exists
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With