0

Is there any way to save/read cookies in the p5.js and p5.play libraries in JS? I'm making a proof of concept for a saving mechanism and I can't find how to save/read the cookies.

Julian
  • 54
  • 4

2 Answers2

1

If you only want to save data locally and have no intent to communicate that information back to a server (e.g., for authentication or identification) you may want ot use localStorage instead of cookies.

p5.js has a simple storeItem/getItem API that is basically a wrapper for localSotrage but it's a bit better: localStorage only works to store strings, but p5.js's API understands how to serialize and deserialize objects (and in particular p5.js data structures) as well.

apsillers
  • 112,806
  • 17
  • 235
  • 239
0

p5.js is "just" JavaScript, so anything you can do in JavaScript, you can do in p5.js. That means if you can't find what you're looking for in the p5.js reference, you can often Google for a more general JavaScript solution.

In your case, try googling "JavaScript save and read cookies" for a ton of results.

I would start here:

Kevin Workman
  • 41,537
  • 9
  • 68
  • 107