Adding cookie law consent to web pages
Quickly including cookie consent on your website
- Open the Pages application.
- Select the page where you want to display the consent message.
- Switch to the Design tab.
- Add the Simple cookie law consent web part onto the page.
Kentico cookies are separated into several cookie levels according to their importance in the system. There are three main levels designed to comply with the law regulations.
Available cookie consent web parts
To display a text message and buttons asking visitors for consent to store cookies in their browsers, use one of the following web parts:
- Cookie law consent
- Simple cookie law consent
Both web parts are implemented by the ~/CMSWebParts/General/CookieLaw.ascx control. The "simple" variant is only a preconfigured version of the same web part. By default, the web parts are not styled, so you need to update your site's CSS stylesheet to get the required look and feel.
Cookie law consent
This web part offers three cookie levels to choose from:
- No cookies
- Only essential cookies
- All cookies
On each level, actions to switch to the remaining levels are offered. You may customize the text messages, available actions as well as button texts.
The Default user cookie level property sets the enforced cookie level before the user makes a choice.
- (Use the system settings) option sets the default user cookie level to the settings defined for the web.config CMSDefaultCookieLevel key (available values are None, System, Essential, Editor, Visitor, All as specified on the Cookie levels page).
The Compare current cookie level to property is a basis for other settings in the web part. It defines a level to which the user's current cookie level is compared. Three states with their own settings are defined depending on the selected level:
- When the current level is below the compared level (Below level behavior settings).
- When the current level exactly matches the compared level (Exact level behavior settings).
- When the current level is above the compared level (Above level behavior setings).
This should give you enough options to configure the web part.
The Preview cookie level property allows you to simulate the user cookie level in Edit and Preview mode.
Simple cookie law consent
This is a preconfigured version of the previous web part. The preset behavior is: Disable cookies by default, request allowing, and once allowed, hide the web part.
Once you place the web part into your website, you might not see the message after switching to the live site. The reason is that all users who access the Kentico administration interface have cookies enabled by default and the cookies are already stored in the browser you are working with. To check whether your configuration of the cookie web part is correct, log out of the administration interface and clear all cookies in your browser. Or try the website in a different browser or computer.