How do I add cookies to the cookie consent?
In case of the individual extension of VIMP, it may be necessary that you have to include your own cookies or cookies of third party providers in the cookie consent.
In the following we explain how you have to proceed.
In order to set your own cookies via PHP, you first have to check in the code whether the user has accepted the cookie consent or the corresponding category. You can check this as follows:
isset($_COOKIE['cookiesAccepted']) && json_decode($_COOKIE['cookiesAccepted'])->preferencesCookies
In the example above we check for accepting the category "preferences". If the condition is true, you can use PHP (>=7.3) to set your own cookie in the appropriate component as follows:
setcookie(nameOfCookie, valueOfCookie, [
'expires' => $expire,
'path' => $path,
'domain' => $domain,
'samesite' => $sameSite,
'secure' => $secure,
'httponly' => $httpOnly,
<?php if(isset($_COOKIE['cookiesAccepted']) && json_decode($_COOKIE['cookiesAccepted'])->partnershipsCookies) != '') : ?>
<?php endif; ?>
Similarly, you can also set third-party cookies in a component using PHP:
<?php if (isset($_COOKIE['cookiesAccepted']) && json_decode($_COOKIE['cookiesAccepted'])->partnershipsCookies): ?>
<?php include_partial('<path_to_partial>'); ?>
<?php endif; ?>
Replace "<path_to_partial>" with the corresponding route, e.g. "start/_myCookie". The corresponding partial must be located in the corresponding template folder (e.g. /templates/pacific/templates/frontend/start).
Last update on 2020/12/08 by Admin.