Improve this Doc View Source $cookies
- $cookiesProvider
- service in module ngCookies
Provides read/write access to browser's cookies.
$cookies exposed properties that represented the current browser cookie values. In version 1.4, this behavior has changed, and $cookies now provides a standard api of getters, setters etc. Requires the ngCookies module to be installed.
Methods
-  get(key);Returns the value of given cookie key ParametersParam Type Details key stringId to use for lookup. ReturnsstringRaw cookie value. 
-  getObject(key);Returns the deserialized value of given cookie key ParametersParam Type Details key stringId to use for lookup. ReturnsObjectDeserialized cookie value. 
-  getAll();Returns a key value object with all the cookies ReturnsObjectAll cookies 
-  put(key, value, [options]);Sets a value for given cookie key ParametersParam Type Details key stringId for the value.value stringRaw value to be stored. options (optional)ObjectOptions object. See $cookiesProvider.defaults 
-  putObject(key, value, [options]);Serializes and sets a value for given cookie key ParametersParam Type Details key stringId for the value.value ObjectValue to be stored. options (optional)ObjectOptions object. See $cookiesProvider.defaults 
-  remove(key, [options]);Remove given cookie ParametersParam Type Details key stringId of the key-value pair to delete. options (optional)ObjectOptions object. See $cookiesProvider.defaults 
angular.module('cookiesExample', ['ngCookies'])
.controller('ExampleController', ['$cookies', function($cookies) {
  // Retrieving a cookie
  var favoriteCookie = $cookies.get('myFavorite');
  // Setting a cookie
  $cookies.put('myFavorite', 'oatmeal');
}]);
 
    © 2010–2017 Google, Inc.
Licensed under the Creative Commons Attribution License 4.0.
    https://code.angularjs.org/1.5.11/docs/api/ngCookies/service/$cookies