Cookies Dynamic Content

In this article we're going to explain how to use Cookies Dynamic Content.

  1. Get
  2. Set

Cookies are a great way to store pieces of data that a user might have encountered on certain pages and that need to be stored on other pages. They are also a great snack! 🍪 You can both get and set Cookies within the Cornerstone Builder. Let's take a look.

Cookie Dynamic Content

Get

Simply put, this grabs a Cookie by the name provided.

{{dc:cookie:get name="cookie_name"}}

You can also provide a fallback in cases where the Cookie is not set.

{{dc:cookie:get name="cookie_name" fallback="FALLBACK_VALUE"}}

Set

Set offers a control for each option available when setting a Cookie. This includes:

  • Name — This is the name you will reference when using Cookie Get above.
  • Value — The value to set and then be returned when grabbing a Cookie.
  • Expires — When the Cookie should expire. This takes in a number value for seconds and will automatically add the current time. If you wish to remove a Cookie, you can set the expiration to -1. Default is set to Never.
  • Path — Where the Cookie is valid on your site. If your value is not / it will be based on the path you have set. If it is / it will be for your entire site. / is the default.
  • Domain — The domain where this cookie is valid. Most browsers will not set a Cookie for another site, but you can set Cookies for a subdomain on your site. It will default to the current WordPress site.
Cookie Set

See something inaccurate? Let us know