How to detect that cookies are disabled in browser with AngularJS
- by user2943082
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?