Improve this Doc  View Source

$cookies

  1. - $cookiesProvider
  2. - service in module ngCookies

Provides read/write access to browser's cookies.

Up until Angular 1.3, $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

Example

angular.module('cookiesExample', ['ngCookies'])
.controller('ExampleController', ['$cookies', function($cookies) {
  // Retrieving a cookie
  var favoriteCookie = $cookies.get('myFavorite');
  // Setting a cookie
  $cookies.put('myFavorite', 'oatmeal');
}]);