# Storing data like a cookie?

**URL:** <https://discourse.processing.org/t/storing-data-like-a-cookie/15258>\
**Category:** Project Guidance\
**Created:** [November 5, 2019, 6:31pm UTC](https://discourse.processing.org/t/storing-data-like-a-cookie/15258 "2019-11-05T18:31:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![KeirMeDear](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@KeirMeDear](https://discourse.processing.org/u/KeirMeDear)\
**Post date:** [November 5, 2019, 6:31pm UTC](https://discourse.processing.org/t/storing-data-like-a-cookie/15258/1 "2019-11-05T18:31:37Z")

</div>

How would you go about holding data in a P5 sketch online if someone came back to it later.

For example, if I had a piece of code where you can choose the fill color of a rect, how could you make it store that value so if you closed the sketch and opened it again it would still be the last fill color you chose.

I understand in processing this would be easier as you could store the value in a text file between uses, but seeing as p5 is web based I’m not sure how to go about it and there doesn’t seem to be anything in the documentation.

Many thanks in advance

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [November 5, 2019, 6:56pm UTC](https://discourse.processing.org/t/storing-data-like-a-cookie/15258/2 "2019-11-05T18:56:30Z")

</div>

> [@KeirMeDear](#):
>
> How would you go about holding data in a P5 sketch online if someone came back to it later.

> [@Creating and Populating a Table From Scratch](https://discourse.processing.org/t/creating-and-populating-a-table-from-scratch/12658/3):
>
> I’ve made a sketch that stores and reads an array of CSV row strings from the browser’s local storage using storeItem() & getItem() respectively; then converts that array to p5.TableRow objects; and finally use p5.Table::addRow() to populate a p5.Table container: card_index_dividers[http://p5js.org/reference/#/p5/getItem](http://p5js.org/reference/#/p5/getItem)[http://p5js.org/reference/#/p5.Table/addRow](http://p5js.org/reference/#/p5.Table/addRow) Each mouse click adds a new p5.TableRow to the p5.Table container, updating the browser’s local storage as well. …

---

<div class="post-metadata">

**Author:** ![KeirMeDear](https://avatars.discourse-cdn.com/v4/letter/k/8c91f0/32.png) [@KeirMeDear](https://discourse.processing.org/u/KeirMeDear)\
**Post date:** [November 5, 2019, 7:16pm UTC](https://discourse.processing.org/t/storing-data-like-a-cookie/15258/3 "2019-11-05T19:16:25Z")

</div>

Ah, getItem() and storeItem() sound perfect, didn’t realise it would be so easy to do 😅

Many thanks as always g2l
