
Add and Remove Cookies Using Shortcodes
If-So allows you to add, remove, or change a value of a cookie using simple shortcodes.
The action happens when the cookie shortcode is rendered. You can paste the shortcodes directly on a page or inside an If-So content version if you’d like to set the cookie based on a condition.
The Cookie Shortcode is useful together with our Cookie Condition, which allows you to display dynamic content based on a cookie name or cookie value.
Adding a cookie using a shortcode
The shortcode below will add a cookie to the user’s browser upon rendering
[ifso-add-cookie name='COOKIE_NAME' value='COOKIE_VALUE' time='3600']
- Make sure to replace ‘COOKIE_NAME’ and ‘COOKIE_VALUE’ with a name and value of your choice.
- The time parameter controls the cookie expiration time (in seconds, 3600 sec = 1 hour)
Replacing the value of an existent cookie
A cookie value will be replaced if a shortcode with a different cookie value will be rendered.
Removing a cookie using a shortcode
Upon rendering, the shortcode below will remove a cookie from the user’s browser
[ifso-remove-cookie name='COOKIE_NAME']
Was this Helpful ?
We're sorry couldn’t be more helpful ☹️