0

I'm working with making my website compliant with EU cookie directives, and on the homepage, I need help with figuring out how to include a cookie warning message, and a the script that disables Google Analytics.

I have made a set of preference cookies to be set for the website.

My site is made with SSIs: meta header newsletter -- page content -- footer

In my Header SSI, before my content, immediately after my body tag opens, I need to include a small page I made to ask for consent for cookies (/inc/cookies.shtml)

how would I get a php script to insert the contents of cookies.shtml?

somewhat wrong code I made :( :

<?php
if ($_COOKIE["shcpr"] == TRUE)
/* If the user has agreed to accept cookies, just stop this script or whatever */
{die()}
else
/* If the shcpr  cookie value is not TRUE, include the warning box */
{include 'inc/cookies.shtml'}

?>

/inc/cookies.shtml

<div id="cookie-outer"> cookie warning content and form to consent and stuff is here </div>
Charles
  • 50,943
  • 13
  • 104
  • 142
Adam Weeden
  • 154
  • 13

2 Answers2

2

I'm pretty sure you should be putting semi-colons on the end of your statements:

<?php
   if ($_COOKIE["shcpr"] == TRUE)
   /* If the user has agreed to accept cookies, just stop this script or whatever */
   { die(); }
   else
   /* If the shcpr  cookie value is not TRUE, include the warning box */
   { include('inc/cookies.shtml'); }
?>
Jeremy Harris
  • 24,318
  • 13
  • 79
  • 133
  • I corrected my mistake, but the error still stands as it is. for some reason the PHP is not being parsed by the server, instead it is being commented as such, i.e. it's appearing to change to I'm going to take a stab in the dark and ask, does it have something to do with me adding it to the top of the header.shtml include? I've set the server to use parse php on all page types I use by .htaccess. – Adam Weeden Aug 01 '12 at 18:17
  • That's a valid point. Check this out: http://stackoverflow.com/questions/839272/how-to-include-php-file-in-shtml-pages – Jeremy Harris Aug 01 '12 at 18:19
  • thanks. it's all sorted now :D now people get a cookie warning and can control cookies http://www.surrealholidays.com/cookies if you're interested to see the final result of cookie crunching... – Adam Weeden Aug 01 '12 at 19:51
0

It's likely that $_COOKIE["shcpr"] contains the string TRUE.

<?php
if ($_COOKIE["shcpr"] == "TRUE")
/* If the user has agreed to accept cookies, just stop this script or whatever */
{die();}
else
/* If the shcpr  cookie value is not TRUE, include the warning box */
{include 'inc/cookies.shtml';}  
?>
wanovak
  • 6,117
  • 25
  • 32