javascriptangularjsng-gridangular-ui-grid

difference between $cookiestore and $cookies in angularjs


What is the difference between $cookiestore and $cookies in angularjs.

I saw the angularjs document.

$cookiestore and $cookies are doing same think, but the only difference is

$cookiestore- can objects put or retrieved from this storage are automatically serialized or deserialized by angular's toJson/fromJson .but $cookies- can't do this

Is the only one difference? or anything else?


Solution

  • I think the description of each in the documentation makes it quite clear:

    $cookie just gives you access to cookies same as if you did by some other method.

    $cookieStore uses cookies to make a key/value storage solution for you.

    So if you are starting something new and want to persist key/value pairs use $cookieStore

    If you want to use existing cookie solution - say read/write cookies from your existing server session system then use $cookie.