Main Content

An easy way to comply with the new cookie law if your site is well designed

Archive - Originally posted on "The Horse's Mouth" - 2012-06-02 15:53:19 - Graham Ellis

If your website is well structured, it shouldn't be a big problem update it to become compliant with the new cookie law - see [here].

I've completed the changes on three sites so far today - Well House Consultants, Well House Manor and Melksham Chamber of Commerce, and I have done considerable work on a fourth - First Great Western Coffee Shop, where we're having to do a change of forum agreement and make sure that people are informed about it, rather than just applying the changes to new visitors.

Let me tell you how I can do so many sites so quickly ;-)

1. On every page on the site, I have added extra code at the top:

  if ($_COOKIE["__utma"] or preg_match('/bot|crawl|spider/',$_SERVER[HTTP_USER_AGENT])) {
    $fill[cookalert] = "";
  } else {
    $fill[cookalert] = "<tr><td class='pageName'> • This site uses cookies - ".
      "see <a href=http://www.wellho.net/web2/cookies.php?which=chamber target=xss>".
      "[here]<a> for details.<br> • If you proceed, we will take that as ".
      "your consent to accept cookies<hr><td><tr>";

  }

In other words, if there isn't a Google Analytics cookie present, and the browser is not an automata, we need to ask the user. We do not want to ask spiders and crawlers, as we don't want to damage our search engine placement by adding in cookie text.

2. That text is displayed within the template:

  <table border="0" cellspacing="0" cellpadding="0">
  %cookalert%


and

3. Providing the information in the extra page at http://www.wellho.net/web2/cookies.php?which=chamber (this is the longest bit)

Since our site's well designed and uses common header scripts and templates, I haven't really had to change every page - just a single teplate and header file on each site. But if you've got a site that's not well structured, there could be an awful lot of work involved.

Here's the different home page on our training site displayed to a brand new visitor and a vistor who already has cookies set:



Here's the different home page on our hotel site displayed to a brand new visitor and a vistor who already has cookies set:



Here's the different home page on the Chamber of Commerce site displayed to a brand new visitor and a vistor who already has cookies set:



The "further information" pages are PHP scripted too (taking care to avoid any more cookies in the process) - the important thing is for them to be complete and understandable - link to them ... Chamber of Commerce, First Great Western Coffee Shop, Well House Consultants and Well House Manor.