Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Accessing and Writing Client-Created Cookies in AngularJS

DZone's Guide to

Accessing and Writing Client-Created Cookies in AngularJS

· Web Dev Zone
Free Resource

Learn how to build modern digital experience apps with Crafter CMS. Download this eBook now. Brought to you in partnership with Crafter Software

AngularJS provides a $cookieStore object that reads and writes cookies. Here is a sample JSFiddle (my new favorite toy) that demonstrates setting a cookie value and bumping it by one each time the button is clicked.

Note - you won't see the number bump in the iFrame-embedded JSFiddle... Only if you jump to the JSFiddle site to test with it! This is Cross-Site Scripting protection in action...

Original discussion source was this Stack Overflow article.

Crafter is a modern CMS platform for building modern websites and content-rich digital experiences. Download this eBook now. Brought to you in partnership with Crafter Software.

Topics:

Published at DZone with permission of Ken Rimple, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}