jQuery(document).ready(function($){
$('.iws-button-accept').click(function(){
$.ajax({
url: '/index.php?option=com_ajax&module=cookie_notice&format=json',
type: 'post',
success: function(){
$('.cookie-notice').hide();
}
});
});
});
The module cookie_notice has a getAjax code in the /Helper/CookieNoticeHelper.php file.
public static function getAjax(){
$module = ModuleHelper::getModule('cookie_notice');
$inputCookie = Factory::getApplication()->input->cookie;
$params = new Registry($module->params);
$cookie_time = $params->get('cookie_time');
$cookie_name = $params->get('cookie_id');
$inputCookie->set($cookie_name, 1, time() + 3600 * 24 * $cookie_time);
return true;
}
In the module's template is checking for cookies, if there is no value, it shows a window with a notification.
$inputCookie = Factory::getApplication()->input->cookie;
$value_cookie = $inputCookie->get($name = $cookie_name, $defaultValue = null);
... here is the notification window
But the code does not save the value of the cookies and constantly shows the window to the visitor, although the visitor accepts the rules.
Please tell me where the bug is in the code, so that cookies are saved and everything works.
Thank you.