How to detect that cookies are disabled in browser with AngularJS
Posted
by
user2943082
on Stack Overflow
See other posts from Stack Overflow
or by user2943082
Published on 2013-10-31T21:49:45Z
Indexed on
2013/10/31
21:53 UTC
Read the original article
Hit count: 184
I use an AngularJS in my current project and try to implement feature which detects does cookies are disable in browser. I have tried to use an AngularJS module "ngCookies" for resolve this issue. The main idea of this feature is to try to create some cookie, then check does this cookie was created and show message if it wasn't. But it didn't worked.
Controller:
someProject.controller('CookieCtrl', ['$scope', '$cookieStore', function($scope, $cookieStore) {
$scope.areCookiesEnabled = false;
$cookieStore.put("TestCookie", "TestCookieText");
$scope.cookieValue = $cookieStore.get("TestCookie");
if ($scope.someValue) {
$cookieStore.remove("TestCookie");
$scope.areCookiesEnabled = true;
}
}]);
View:
<div class="main" data-ng-controller="CookieCtrl">
<div class="warning_message" data-ng-show="!areCookiesEnabled">
<span data-ng-bind="areCookiesEnabled"></span>
</div>
</div>
Can anybody tell me where is my mistake?
© Stack Overflow or respective owner