I want to authenticate users through api, when username and password is right it returns a token and store on local storage using ngStorage but I read some articles that it's not secure saving token on localStorage, and they made reference to storing it to cookies Http. How can I store the token on cookies Http and is it secure or is there a better way of handling token authentication
$scope.loginUser = function(){
    $http({
      method: 'POST',
      url: 'ourdomain.com/api/token',
      headers: 
      {
          'Content-type': 'application/x-www-form-urlencoded',
      },
      data: 
      'UserName=' + $scope.username + 
      '&Password=' + $scope.password 
      }).success(function(data, status) {
               $localStorage.token = data;
               console.log(data);
      })
      .error(function(data, status) {
          console.log("Error");
      });
}
 
     
     
    