Forum Academy Marketplace Showcase Pricing Features

[Plugin Announcement]: Cookies

We are excited to announce the launch of the Bubble plugin, Cookies!

Easily manage user browser’s cookies. Cookies allow you to store user’s data without using Bubble’s database

Use cases: Save user preferences for language, dark/light mode, currency, country, visit numbers, last visit, statistics etc

Features:

  • Read a cookie by name
  • Delete a cookie by name
  • Add a cookie: name + value + expiration (in days)
  • Read all cookies

Demo: demo | editor

Full Description, Documentation & Screenshots: link

We hope you enjoy using this plugin to add Cookies feature to your Bubble apps. No matter where you are in the world, stay safe, stay creative, and stay connected to each other!

Plugin page:

15 Likes

Hi @BubbleSam . I’m considering using this to create a cookie consent/settings area for my site’s users.

I have a couple questions after checking out the demo/editor. Let’s say I want to use this to ‘write’ my google analytics cookie.

  1. where do you suggest I place the cookie script?
  2. what do I use for the ‘value’? your example looks like a Bubble DB value, but the plugin description states that you’re ignoring the DB. Would you suggest that I store all of my cookies in the DB and then write them to the browser session using the plugin write function?
  3. Will this expose cookies set by Bubble itself, or only cookies that I define using the plugin?

Thanks,
Chris

Hi @noyourbroker ,
Thank you for your interest!

  1. You should add the workflow actions on the page where you want to read/write your Cookies
  2. Cookies are stored in the user’s browser and we de not use a database on the demo page. In the create cookie block we provide a ‘value’ from the text input. The actual data source may be different depending on your app. Some examples:
  • user input (for example, user chose a preferred language and you can store it in Cookies)
  • data generated by your app (access token etc)
  • database
  • etc

You normally shouldn’t store cookies in the database because you can consider cookies as a kind of database (stored in the user’s browser)

  1. Cookies are associated with a domain and could be generated by your application (using this plugin), Bubble engine itself, or other plugins you use

Don’t hesitate to contact me if you have any further questions!

Not sure if this is a dumb question, but could you use the Cookies plugin to store small amount of data, e.g. submitted via a form, in the browser when users are offline - and then access the cookie to save data into a Bubble database when connectivity resumes?

1 Like

Hi @teachamantofish ,

Actually yes, it could be! If you have a long form users need to fill in, you can store it to cookies first and then when user click on the “Submit” button, save the data from Cookies to Database.

But probably you could avoid using cookies and just save form fields to the database once a field is updated. Of cause user needs to be online but he won’t loose all the form data.

Don’t hesitate to contact me if you have any further questions!

2 Likes

What are the advantages of cookies over state?

is it possible to save a cookie between a domain and its subdomain?

Unfortunately I think it won’t work…

Trying to use this for my darkmode/lightmode.

Can you help me figure out the flow for this?

I am not sure how to setup an action that can detect when option is set to true via cookies. It’s a little confusing.

I want to be able to use this throughout my entire workflows somehow - so I can make all my darkmode conditions “when cookie is yes” show the color type of thing or is this not possible?

Hi there @stonkpub ,
Thank you for your question!
You should be able to read a cookie value using the “Read” action:

After that, you can access the “cookie” shared state to read the value.

Hi @BubbleSam ,

Thanks for this plugin! Is there a way to detect when the cookie is expired and then trigger a workflow action?

I thought when the cookie expires, it will be dropped and the read cookies value would be empty, so I to set when read cookies value is empty → trigger an error message -->. However, this wouldn’t work, it seems the Cookie A’s value is always empty in this workflow even through I can see the cookie in my browser.

Please let me know your thoughts.
Thanks.

Hi @ezhang !

Expired cookies are removed by browser, so you can read cookies’s value and if it’s empty, it means that the cookie doesn’t exist.

Hum… if you are sure that the cookie exists but you can’t read it with the plugin that becomes weird… Could you please create a simple demo page to reproduce the issue?