angularjs - Cookie is still present after expiration date -


so i'm trying use ngcookie ($cookies) set boolean in angularjs. can see in example below, "someflag" should true, if cookie still present. cookie expiration set 30 seconds, after 30 seconds, "someflag" still true.

so how manage find out wether cookie expired or not?

var peekerhidecookie = $cookies.get('peekerhidecookie'); console.log(peekerhidecookie); if (peekerhidecookie == 'true'){     $scope.someflag = true; }  $scope.test = function () {     var d = new date();     d.setdate(d.getseconds() + 30);     $cookies.put('peekerhidecookie', 'true', {expires: d});     $scope.someflag = true; } 

use d.setseconds(d.getseconds() + 30) insetead of d.setdate()

 $scope.test = function () {         var d = new date();         d.setseconds(d.getseconds() + 30);         $cookies.put('peekerhidecookie', 'true', {expires: d});         $scope.someflag = true;     } 

var d = new date();  console.log(d);  d.setseconds(d.getseconds() + 30);  console.log(d);         


Comments

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -