-
Notifications
You must be signed in to change notification settings - Fork 1
/
CookieNotice.php
58 lines (54 loc) · 2.47 KB
/
CookieNotice.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php
/**
* MonstrousCookies, created by James Phillips <james@jamesphillipsuk.com> September 2016.
* MonstrousCookies is a PHP plugin to allow sites to comply with the EU Cookie Law by informing users of a site's cookie policy.
* CookieNotice.php is a part of MonstrousCookies.
*
* Copyright (C) 2016 James Phillips, Released under the GNU GPL v3.0 or later.
*
* This program is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3 of the License,
* or (at your option) any later version. This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
* You should have received a copy of the GNU General Public License along with this program.
* If not, see <http://www.gnu.org/licenses/>.
*
**/
//Quick flyout notice for cookies.
$value="On";
if ( !isset ($_COOKIE['ThisSiteNameCookies']) || $_COOKIE['ThisSiteNameCookies'] != $value ) //Please re-name ThisSiteNameCookies with the name of your website.
{
?>
<div id="CookieMonster">
<p id="Cookies">By using this site, you agree to <a href="http://ThisSiteName/cookies/">our cookie policy.</a></p> <!-- Replace http://ThisSiteName/cookies/ with a link to your cookies page -->
<button id="Exit">X</button><!-- You can replace X with Exit for better readability -->
</div>
<script>
var button = document.getElementById('Exit');
button.onclick = function()
{
var div = document.getElementById('CookieMonster');
if (div.style.display !== 'none')
{
jQuery('#Cookies').text( 'Thanks!');
jQuery('#CookieMonster').slideUp();
}
else
{
div.style.display = 'block';
}
};
</script>
<?php
setcookie("ThisSiteNameCookies", $value, time() + (86400 * 10)); //Again, please re-name ThisSiteNameCookies with the name of your website.
}
elseif ( $_COOKIE['ThisSiteNameCookies'] == $value )
{
//there is a ThisSiteNameCookies session. Someone has seen the notice. Do nothing.
}
else //This should never happen, but here's a backup measure just in case.
{
echo '<div id="CookieMonster"><p id="Cookies">Something's gone wrong! Please <a href="mailto:webmaster@ThisSiteName">inform the site!</a></p></div>'; //Please replace webmaster@ThisSiteName with your email address
}
?>