EU Cookie Experimentation
Posted: Sat 26 May 2012 12:56 am
Created a new thread so that I don't hijack Steve's thread which deals with how he is dealing with the EU rules. Don't want to splinter that as he has a real requirement and I am just playing around with ideas on this.
That being said, I have made a change to my "experiment".
Originally, I used code from http://cookiecuttr.com/ which uses a Jquery and Javascript solution to the issue. The problem I had with it, was that I still would have session ID's stored on the user and taking that out causes serious problems for the site.
So my next attempt was to remove all of that... and replace it with a simple PHP set of commands.
The first gets placed in the control php script (index.php) which is used by the site to direct the user to whatever page they have asked for. In it, it has a simple cookie check and if it doesn't find it it sends the user to a stripped down cookies.php script.
Index.php Redirect
The code in the index.php file is:
Basically, it looks for if a cookie exists with the name cc_cookie_accept. IF it exists, the code flows through to the normal process and the user gets the normal website.
Cookies.php script
This script uses the basic format of the website, but is not flowing through the normal processing scripts. At the top of the script it checks to see if the cookie is set. If it is, it redirects the user to the real site.
If that falls through, it then checks to see if the user has accepted (via a form) the use of cookies. This code, then sets a cookie and sends the user back to the same script (Where the above check would then send the user to the real site):
If that falls through, the page displays the info about why, and presents the user with a form to accept or not accept the cookie. This code is basically just HTML...
When the user hits the Submit button, the choice is sent to the same script which is processed by the code at the top of this post.
If the user doesn't accept cookies, they never get to the real site. No cookies, no site.
Missing from this at the moment is a check for robots which you really wouldn't want trapped by this. Need to come up with a simple common method to identify them. Looking into that now.
You can see this in action by going to http://cumulus.tnetweather.com
of course, if you have already accepted the cc_cookie_accept cookie, it won't do anything. So you would need to delete that cookie to see it work.
Note that this removes ALL of the jquery stuff that was put into the site originally. I just removed that now.
That being said, I have made a change to my "experiment".
Originally, I used code from http://cookiecuttr.com/ which uses a Jquery and Javascript solution to the issue. The problem I had with it, was that I still would have session ID's stored on the user and taking that out causes serious problems for the site.
So my next attempt was to remove all of that... and replace it with a simple PHP set of commands.
The first gets placed in the control php script (index.php) which is used by the site to direct the user to whatever page they have asked for. In it, it has a simple cookie check and if it doesn't find it it sends the user to a stripped down cookies.php script.
Index.php Redirect
The code in the index.php file is:
Code: Select all
if(!isset($_COOKIE['cc_cookie_accept'])) {
header("Location: /cookies.php");
exit;
}Cookies.php script
This script uses the basic format of the website, but is not flowing through the normal processing scripts. At the top of the script it checks to see if the cookie is set. If it is, it redirects the user to the real site.
Code: Select all
if(isset($_COOKIE['cc_cookie_accept'])) {
header("Location: /");
exit;
}Code: Select all
if(isset($_GET['cookie'])) {
if($_GET['cookie'] == "ACCEPTED") {
setcookie("cc_cookie_accept","cc_cookie_accept",time()+60*60*24*364);
}
header("Location: /cookies.php");
exit;
}Code: Select all
<center><form >
Accept Cookies From this Site: <input type="radio" name="cookie" value="ACCEPTED" checked="checked" /> <br/>
Decline Cookies: <input type="radio" name="cookie" value="decline"/><br/> <br/>
<input type="submit" name"submit" value="Set Your Preference"/>
</form></center>If the user doesn't accept cookies, they never get to the real site. No cookies, no site.
Missing from this at the moment is a check for robots which you really wouldn't want trapped by this. Need to come up with a simple common method to identify them. Looking into that now.
You can see this in action by going to http://cumulus.tnetweather.com
of course, if you have already accepted the cc_cookie_accept cookie, it won't do anything. So you would need to delete that cookie to see it work.
Note that this removes ALL of the jquery stuff that was put into the site originally. I just removed that now.