View Single Post
Old 06-10-2012, 08:10 PM   PM User | #13
mlseim
Master Coder

 
mlseim's Avatar
 
Join Date: Jun 2003
Location: Cottage Grove, Minnesota
Posts: 9,045
Thanks: 8
Thanked 1,029 Times in 1,020 Posts
mlseim has a spectacular aura aboutmlseim has a spectacular aura aboutmlseim has a spectacular aura about
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"$valuetime()+(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"$valuetime()+(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.

?>

Last edited by mlseim; 06-10-2012 at 08:17 PM..
mlseim is offline   Reply With Quote
Users who have thanked mlseim for this post:
Pezmo82 (06-10-2012)