Skip to main content

Popups

Save user preferences as cookies

Description

  • Popups will store data as cookies
  • Use popups to save preferences that can be expressed as: true, false, or dismiss
  • Cookies data will expire at the end of browser session
  • For other use cases please resort to a custom script

Create

  • Go to panel
  • Scroll down to 'Popups'
  • Add new popup

Values

Popups will store data as key=value pairs in cookies:

  • key: Popup unique identifier
  • value: 'true' | 'false' | 'dismiss'

Reset

Allow users to clean their data with a reset button

Reset Popups (working example)

  • Link: a[data-action="popup-reset-all"]
  • Button:button[data-action="popup-reset-all"]
  • Markdown: <a class="btn" href="#!" data-action="popup-reset-all">Reset All Popups</a>

Retrieve data

JavaScript

// get all cookies
getCookie();

// get cookie
getCookie('key');

// set cookie
setCookie('key', 'value');

// remove cookie
removeCookie('key');

PHP

// get all cookies
<?php $_COOKIE ?>

// get cookie
<?php $_COOKIE['key'] ?>

// set cookie
<?php setcookie('key', 'value') ?>

// delete cookie
<?php setcookie('key', '', 1) ?>

Kirby

// these cookies will be hashed
// they can not be retrieved by JS
// ----- ----- -----

// get all cookies
<?php Cookie::get() ?>

// get cookie
<?php Cookie::get('key') ?>

// set cookie
<?php Cookie::set('key', 'value') ?>

// remove cookie
<?php Cookie::remove('key') ?>

🤖 Privacy Policy

We use cookies to improve your experience. Find out more in our privacy page.