First you need to deal with the top banner itself.
If they click NO, you need to have it go to a script called "nocookie.php".
So, create that script and just put this in it for now.
nocookie.php
PHP Code:
<?php
$value="N";
setcookie("permission", $value, time()+(3600*24*7)); /* expire in 1 week */
header ('location: index.php');
?>
Make it so that when they click "NO", the javascript will run that PHP script called "nocookie.php".
Create another script called "yescookie.php";
yescookie.php
PHP Code:
<?php
$value="Y";
setcookie("permission", $value, time()+(3600*24*14)); /* expire in 2 weeks */
header ('location: index.php');
?>
The yescookie.php script will execute after the confirmation box you made.
At the top of your script that displays the permission box (banner), you'll
need to see if the cookie called "permission" exists, and if it does, is the value "Y"?
If the value is "Y", you won't display that banner.
After 2 weeks, the banner will reappear, because the cookie is erased.
top of scripts
PHP Code:
<?php
if(isset($_COOKIE['permission'])){
if($_COOKIE['permission']=="Y"){
// Permission to accept cookies
// so don't display the banner.
// Maybe let them know they are getting cookies?
// (banner won't appear)
}
else{
//
// No permission to accept cookies
// You can display something that tells
// them they won't be getting any cookies.
// (banner won't appear)
}
}
else{
// display the banner here
// banner stuff
// (banner will be appearing here)
}
// the rest of your script here ...
// Every other place in your website where you will be writing a cookie,
// you'll need to recheck $_COOKIE['permission'] to make sure the value is "Y"
// before you write any other cookies.
?>