Sharing Top Content from the Angular-sphere.

Understanding cookies in AngularJS

Learn And Understand cookies in Angular.JS
#Angularjs

  • Keywords : $cookies vs $cookieStore, cookies vs cookieStore, difference between cookies and cookieStore, difference between $cookies and $cookieStore service

    AngularJS provides module for reading and writing browser cookies.

  • This module provides two services for cookie management: $cookies and $cookieStore.
  • This service provides read/write access to browser’s cookies.
  • If you want to use existing cookie solution, say read/write cookies from your existing server session system then use $cookie.
  • If you are creating a new solution which will persist cookies based on key/value pairs, use $cookieStore.

AngularJS provides ngCookies module for reading and writing browser cookies. To use it include the angular-cookies.js file and set ngCookies as a dependency in your angular app. This module provides two services for cookie management: $cookies and $cookieStore.

@DotNetTricksIn: Learn And Understand cookies in Angular.JS
#Angularjs

file and set ngCookies as a dependency in your angular app. This module provides two services for cookie management: $cookies and $cookieStore.

This service provides read/write access to browser’s cookies. If you want to use existing cookie solution, say read/write cookies from your existing server session system then use $cookie.

$cookieStore is a thin wrapper around $cookies. It provides a key-value (string-object) storage that is backed by session cookies. The objects which are put or retrieved from this storage are automatically serialized or deserialized by angular to JSON and vice versa.

If you are creating a new solution which will persist cookies based on key/value pairs, use $cookieStore.

I hope you will enjoy the cookies in AngularJS while developing your app with AngularJS. I would like to have feedback from my blog readers. Your valuable feedback, question, or comments about this article are always welcome.

Understanding cookies in AngularJS

Comments are closed, but trackbacks and pingbacks are open.