0 users online. Create an account or sign in to join them.Users

Search

Hallo, I need to set up a European cookie law banner. I tried the Cookie Law extension, but attaching the DS to a page makes the page blank.
Any alternative workaround? Already made JS?

Thanks!

I think the following should work if you add an element into your template(s) with a class of cookie-container.

  if (document.cookie.replace(/(?:(?:^|.*;s*)mysitenamecookies*=s*([^;]*).*$)|^.*$/, "$1") !== "true") {
    jQuery('.cookie-container').show();
   document.cookie = "mysitenamecookie=true; expires=Fri, 31 Dec 9999 23:59:59 GMT; path=/";
  }

Obviously you'll need to populate .cookie-container with a relevant message.

This would show a banner to new visitors which would only show on their first pageview. Adding a close button to the container would be a simple enhancement that would be easy to achieve.

If you wanted to require people to acknowledge the warning, move the line that sets the cookie into a click handler rather than letting it happen automatically.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details