
In Opencart 4, the cookie and GDPR management is available by default for the legal policies, where you can select the pages for them and show the popup at the footer. You can set them at Admin >> System >> Settings >> Option tab >> Legal carousel tab where you can select the Coolie policy page, GDPR Policy page, and GDPR limit time in days.

Cookie Policy: Display the Cookie policy as part of the EU Law.
GDPR Policy: Display the Cookie policy as part of the EU Law.
GDPR Limit: Limits the number of days before a personal data removal request is performed after its approval. Required for returns and chargebacks and fraud prevention.
Once you set this you will see the popup at the bottom of the website like below:

Once clicked “Yes, that’s fine!” it will not show the days that you set on the GDPR limit, here in our example it is 180 days.
For Opencart 2 and 3, we have developed a module called “Cookie bar for OpenCart 2 and 3”
How to change the Cookie or GDPR text which you see in the popup?
You can change the text of the cookie text “This website uses cookies. For more information click here.” to your desired text. For that you need to login to the Opencart admin section >> Design >> Language Editor >> Add New (blue button) and enter the following:
Store: Default
Language: English
Route: common/cookie
Key: text_cookie
Default: Auto-filled and not editable
Value: Enter your desired text, we are entering below:
We use cookies to improve your experience of this website. To find out more information about our cookies, please see our <a href=”%s” class=”alert-link modal-link”>Cookies policy</a>

Then click Save. You can make changes to the agree and disagree button also, we added two more language changes like below:

After these changes, the frontend cookie bar shows like below:

In Opencart 4 cookie bar persists, fix the cookie bar to hide once clicked
In Opencart 4 the cookie bar persists even though you clicked the agree on the button or the disagree button. We have the following fix for now:
Open the catalog/controller/common/cookie.php file and look for confirm method:
public function confirm(): void and find the following lines of code:
$option = [
'expires' => time() + 60 * 60 * 24 * 365,
'path' => !empty($_SERVER['PHP_SELF']) ? dirname($_SERVER['PHP_SELF']) . '/' : '',
'SameSite' => $this->config->get('session_samesite'),
];
From the above code, remove dirname($_SERVER[‘PHP_SELF’]) .
With that the confirm method looks like the below:
public function confirm(): void
{
$json = [];
if ($this->config->get('config_cookie_id') && !isset($this->request->cookie['policy'])) {
$this->load->language('common/cookie');
if (isset($this->request->get['agree'])) {
$agree = (int) $this->request->get['agree'];
} else {
$agree = 0;
}
$option = [
'expires' => time() + 60 * 60 * 24 * 365,
'path' => !empty($_SERVER['PHP_SELF']) ? '/' : '',
'SameSite' => $this->config->get('session_samesite'),
];
setcookie('policy', $agree, $option);
$json['success'] = $this->language->get('text_success');
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
With these changes, the policy cookie is set and the policy cookie value is set to 1 or 0 as per the selection. You can see what cookie value is set by right-clicking on the page >> Inspect element (Chrome browser) >> Application tab >> Cookies tab on the left >> select the URL >> and you can see the policy value. Here in the example below the policy value is set to 1 as we clicked the accept cookie button.

In this way, you can manage the Cookies policies and GDPR policies on the Opencart websites of version 4 and for versions 3 and 2 you can use the Cookie module. Hope you liked this article, please subscribe to our YouTube Channel for Opencart video tutorials. You can also find us on Webocreation Twitter and Webocreation Facebook. Please let us know if you have any questions or concerns.