Improve this Doc View Source
Deprecated: (since v1.4.0)

Please use the `$cookies` service instead.

## Overview

Provides a key-value (string-object) storage, that is backed by session cookies. Objects put or retrieved from this storage are automatically serialized or deserialized by AngularJS's `toJson`/`fromJson`.

Requires the `ngCookies` module to be installed.

## Dependencies

- `$cookies`

## Methods

- ###

  `get(key);`

  Returns the value of given cookie key

  #### Parameters

  Param | Type | Details
  --- | --- | ---
  key | string | Id to use for lookup.

  #### Returns

  Object | Deserialized cookie value, undefined if the cookie does not exist.

- ###

  `put(key, value);`

  Sets a value for given cookie key

  #### Parameters

  Param | Type | Details
  --- | --- | ---
  key | string | Id for the `value`.
  value | Object | Value to be stored.

- ###

  `remove(key);`

  Remove given cookie

  #### Parameters

  Param | Type | Details
  --- | --- | ---
  key | string | Id of the key-value pair to delete.

## Example

    angular.module('cookieStoreExample', ['ngCookies'])
    .controller('ExampleController', ['$cookieStore', function($cookieStore) {
      // Put cookie
      $cookieStore.put('myFavorite','oatmeal');
      // Get cookie
      var favoriteCookie = $cookieStore.get('myFavorite');
      // Removing a cookie
      $cookieStore.remove('myFavorite');
    }]);