CodeIgniter icon indicating copy to clipboard operation
CodeIgniter copied to clipboard

EU "cookie law" compliance

Open alexbilbie opened this issue 14 years ago • 36 comments

I've added a new branch called feature/eu-cookie-law (https://github.com/EllisLab/CodeIgniter/tree/feature/eu-cookie-law).

This branch makes the CI session library compliant with the EU "cookie law" which states that cookies should not be set on a user's computer unless they have given the [EU based] site permission to do so.

There is a new config variable called $config['cookie_consent_required']. When this is set to TRUE no cookies will be set when the session library is first loaded (if a session cookie doesn't exist already), and any existing session cookies will be destroyed.

Cookies now won't be set until the user has given explicit consent. This can be controlled using two new functions in the cookie helper - cookie_consent_granted() and cookie_consent_withdrawn().

What do people think?

Note this commit only changes the automated behaviour of the session library, cookies can still be set manually using the cookie helper

alexbilbie avatar May 21 '12 15:05 alexbilbie

Just to clarify some points that have been brought up on Twitter. The reason why this should be fixed at framework level instead of at application level is because CodeIgniter will drop a session as soon as the session library is loaded (and regardless of whether or not any session data is then actually set) so the user isn't given a choice in the matter.

Also this default cookie contains "private information" (IP address, user agent, etc) instead of functional data (i.e. strictly necessary to operate the website).

alexbilbie avatar May 23 '12 17:05 alexbilbie

No cookies should be set when the session library is first loaded.

This is the bug which needs to be fixed at a framework level. If you care about performance then this needs to be resolved, it will make anyone who cares about web performance happy.

Once this has been resolved, surely the cookie_consent_granted() function isn't required at a framework level anymore? Isn't this something Application developers can now manage on their own, now they have complete control over when a cookie is dropped with the browser?

(p.s. think it's great that more people are getting directly involved developing CI, so hat tip to that :D )

deplorableword avatar May 23 '12 17:05 deplorableword

AFAIK the exact details of the cookie law are still debatable. Specifically, some people think you absolutely must get permission before setting any cookies; others are of the opinion that you can set cookies straight away as long as you ask permission at some point, and remove them if the user declines.

I haven't read a huge amount on the cookie law so I can't really back either side up. I personally believe the latter, so I'd much rather the session library continued to act as normal until told otherwise. Yes it's law, but not for everyone, so essentially disabling the session library by default could have a negative affect on people that don't have to suffer from EU laws. Then there's the potential issue that the law may differ between various EU countries, though by how much I don't know.

When it comes down to it, having measures in place in the core to help everyone abide by laws (whether they agree with them or not) can only be a good thing -- as long as I have to enable it myself. Just my two pennies, feel free to take them with a pinch of salt.

dshoreman avatar May 23 '12 18:05 dshoreman

I believe that adding features or config options based on laws or regulations passed in certain jurisdictions is a really bad idea. CodeIgniter is a framework, and it's not a framework's job to manage things like this via built-in functionality.

Of course the session library should be fixed so it does not automatically set cookies when no data is actually saved in sessions, etc. But this is an entirely separate concern.

joellimberg avatar May 23 '12 22:05 joellimberg

It is a framework's job to make common features easier to develop and if a law makes it common enough - so be it.

narfbg avatar May 23 '12 22:05 narfbg

My main problem is actually that this supposed "cookie law" is so complex that cookie management cannot be boiled down to "Yes/No". Cookie usage restrictions are based on their intent, the status of the web application's owner, etc.

If there's a single "consent" setting, there will likely be incorrect or unnecessary usage.

I'll repeat that I do agree that CI should be smarter about setting cookies overall, so using the Session lib wouldn't automatically create and start managing cookies and session information (when nothing's actually stored).

joellimberg avatar May 23 '12 22:05 joellimberg

@deplorableword yes

@daveshoreman UK law says you should ask permission before dropping any cookies, other EU states may have slightly different wording

@joellimberg bringing this issue to light might result in CI's session library being re-architected anyway and if it means that CI is compatible with the law then great however it is an important issue

alexbilbie avatar May 23 '12 23:05 alexbilbie

I am working on a pretty good session storing by using browser fingerprints.

I'm using the class from http://www.wolf-software.com/downloads/php-classes/security-classes/web-fingerprint-class/ To generate a hash with all the user information that is provided by the header requests of the users. So far with a site that has about 10.000 pageviews a day it's still making unique headers and keeping track of the fingerprint browsing. Only requirement is that you place the <meta http-equiv="X-UA-Compatible" content="IE=edge" /> in your header so that ie doesn't skip from mode 7 to 9 to 8 to 7 between pages when compatibility mode is enabled by the users.

Now i'm looking for a way to use this fingerprint hash to connect to the session class to retrieve all the information, that way I bypass cookie law in the netherlands. Users get annoyed if they have to give permission to place a cookie and to be informed that their information is retained on our server bladiebla...

Plus it is another step in preventing session hijacking, because the session id is retrieved by matching fingerprints instead of cookies. My fingerprints at this time have a lifetime of about 10 minutes.

Is this a feasible option for getting past cookie law? or do I need to write my own session class.

mdibbets avatar May 25 '12 08:05 mdibbets

@mdibbets I would be very very cautious when using browser fingerprints as session ids (essentially).

Sure, it might still be unique at 10.000 users, but the randomness of the fingerprint is still extremely low compared to a truly random id.

joellimberg avatar May 25 '12 10:05 joellimberg

@mdibbets you're not actually complying with the law there because you're still dropping cookies without consent

alexbilbie avatar May 25 '12 17:05 alexbilbie

well, the hash i compile has the user ip, resolved adress unique identifier with its make up. plus the fingerprint will get dedtroyed with session destroy or if age > session timeout. so far with 12.000 visitors spanning 3 days running a test on uniqueness there hasnt been one thats double. for sessions with an average visit lifespan of 5-15 minutes. for my requirements its unique enough. maybe google would have problems with it, but for my requirements its unique enough.

And theres no cookie dropping because I overwrite Session->_set_cookie that uses the native setcookie and the Input->cookie and Input->set_cookie functions.

So long as the programmer sticks to the codeigniter cookie settings and functions there is no cookie dropping, and thusly I comply with the law because I do not store information on the users computer/smartphone.

Verzonden via Yahoo! Mail op Android

mdibbets avatar May 25 '12 18:05 mdibbets

The ICO (UK information commission office) updated their guidance yesterday to say that "implied consent" is a valid form of consent - this means that you can drop cookies without first asking the user however you should tell them that you've done so and if they want to change it they can remove them from their browser.

See http://www.ico.gov.uk/news/blog/2012/updated-ico-advice-guidance-e-privacy-directive-eu-cookie-law.aspx

Note this just for sites operating in the UK - other EU states may still require explicit consent before any cookies are dropped.

alexbilbie avatar May 26 '12 18:05 alexbilbie

In the Netherlands you can drop cookies that are necessary for the operation of a site (such as user settings and preferences). When you are collecting data and/or sharing information with third parties you should ask permission before the cookie is set (allowing them to be removed isn't good enough).

I am the tech of a large blog, and our users kan add youtube etc. to the comments. As youtube (and Vimeo and... and...) also sets a cookie it is almost impossible for us to comply with the law without removing features for the users. I understand the intention of the law and approve of that, but the complications are severe (and in the end not addressing the real problem).

jberculo avatar Jun 27 '12 23:06 jberculo

I have finally received a reply from the UK's Information Commissioners Office:

Thank you for your email dated 29 May 2012 about the new Cookie Regulations.

Please accept my apologies for the delay in responding to you, our office is currently dealing with large volumes of work. This has meant that we have been unable to deal with incoming correspondence as promptly as we would like.

You have asked ‘if a user's IP address and browser user agent string are personal data.’

Our view is that in many cases an IP address or browser string will constitute personal data. This is because the information can be used to monitor an individual’s behaviour and make decisions which will affect them. However, it can be difficult to determine with any certainty whether the information is personal data, because it could relate to several individuals who cannot be identified. Our guidance is that this information should be treated as personal data to ensure compliance.

So in their eyes CI would need to ask permission before dropping the session cookie

alexbilbie avatar Jul 26 '12 15:07 alexbilbie

So it's even more important that the session library should be fixed so that it does not drop a cookie when it's first loaded. Any chance it can be fixed in the next release?

deplorableword avatar Jul 26 '12 15:07 deplorableword

Well the current method of handle cookies in CI isn't particulary OO, since there's function calls to set_cookie without storing the cookies as objects until they are destroyed.

I made a suggestion for a new cookie class that gives you more control for each cookie so that it's easier to quick adapt to legal frameworks that change over the time.

This class is working most like a kind of template right now and is incomplete.

Feel free to ask, suggest or propose another solution. I'm willing to implement full working cookie management solution, if others agree with the proposal.

http://pastebin.com/udXxG8fg

ghost avatar Jan 07 '13 09:01 ghost

cookie law is dead http://www.netmagazine.com/news/cookie-law-dead-132540

richwestcoast avatar Feb 06 '13 17:02 richwestcoast

richwestcoast, it doesn't matter. The code must be object oriented enough to quickly adapt it's behaviour to all kinds of unpredictable political acts happening in any place on the planet. The cookie management in CI is quite incomplete in my eyes. I made a suggestion for a cookie/cookiegroup class before.

https://github.com/EllisLab/CodeIgniter/pull/2126

ghost avatar Feb 06 '13 19:02 ghost

@richwestcoast @and-ers It's also classy to ask before dropping the cookie. And the CI cookie library shouldnt drop a cookie when it's loaded - it will be a bit more extendable.

novium avatar Mar 10 '13 08:03 novium

Is this issue/request going to be implemented or is the session library going to be fixed?

marcvdm avatar Jun 01 '13 23:06 marcvdm