Cookie Disclosure & Explicit Opt-In
Home
Info

Minimal Explicit Opt-In Script

This script is the basic for a explicit Opt-In blocking content webpage and display a own webpage in PHP documents and in content management systems under any URL instead the real webpage content.

The blocking content webpage appears without the cookie in PHP documents and on any webpage of a content management system instead of the real contents.

You can add your privacy policy to this blocking content webpage.

The blocking content webpage contain a OK button who set a cookie. When the cookie is set the blocking conten webpage disappears and does not appear anymore during the visit of webpages on the same internet domain name. The cookie will be deleted when the browser is closed.

These explicit Opt-In script works with PHP and Javascript only.

The Javascript set cookie function in the explicit Opt-In script differentiates between www and non-www Internet Domain Name URLs and distinguishes subdomains.

The PHP script snippet has included a pass-through feature for Search Robots, Webcrawler and Spider.
With the searchrobot/webcrawler/spider (user agent) rule, there is a danger that search engines classify this as cloaking.

1.) You can design all CSS and text yourself.
2.) The searchrobot/webcrawler/spider (user agent) rule can be extended or deleted.
3.) Please paste the script directly to the beginning of the PHP document before any other code starts.
You can control and test it with these three buttons.
    Reload Webpage
Please note: In addition, Piwik Tracking Tool is active on this webpage (cookies with "_pk").

<?php
$cookie_name = "eudsgvocookie" . str_replace(".", "", $_SERVER['SERVER_NAME']);
// On the line below the reloadurl variable with urls include possible query strings
$reloadurl = (isset($_SERVER['HTTPS']) ? "https" : "http") . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
if (array_key_exists($cookie_name, $_POST)) {
setcookie($cookie_name, "accepted", 0, "/");
}
// On the line below the if (!searchrobot/webcrawler/spider, user agent) statement
if (!preg_match('/google|bing|yandex|bot|crawl|spider/i', $_SERVER['HTTP_USER_AGENT'])) {
// On the line below the if (!cookie) statement
if ((!array_key_exists($cookie_name, $_POST)) && (!isset($_COOKIE[$cookie_name]))) {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="robots" content="noarchive">
<meta name="robots" content="noindex">
<style>
.optinnote {
display:block;
position:fixed;
top:25%;
left:0px;
right:0px;
margin:0 auto;
width:50%;
height:50%;
overflow:auto;
overflow-x:hidden;
box-sizing:border-box;
padding:10px;
text-align:center;
background-color:#000000;
color:#ffffff;
font-family:Helvetica,Arial,Geneva,sans-serif;
font-size:1em;
}
.inputbutton {
font-size:2em;
cursor:pointer;
}
button {
font-size:1.2em;
cursor:pointer;
}
</style>
</head>
<body>
<div class="optinnote">
<h1>
<!-- Opt-In header text -->
Opt-in
</h1>
<span lang="en">
<!-- Opt-In info text -->
The website uses Cookies, Tracking and Monitoring.
</span>
<br>
<br>
<form action="<?php echo $reloadurl; ?>" method="POST">
<!-- The "value" (text) of the OK button -->
<input class="inputbutton" type="submit" value="OK" name="<?php echo $cookie_name; ?>">
</form>
<br>
<br>
<!-- The text below from the OK button -->
Your browser must accept cookies.
<br>
<button type="button" onclick="var x = document.cookie;alert (x);">
<!-- The text of the display cookies button -->
Display Cookies
</button>
<br>
(Javascript required)
<br>
<br>
<a href="<?php $reloadurl ?>">
<button type="button">
<!-- The text of the reload webpage button -->
Reload Webpage
</button>
</a>
<br>
<br>
<!-- You can insert more text here. -->
</div>
</body>
</html>
<?php
exit;
} // The closed curly brace for the if (!cookie) statement
} // The closed curly brace for the if (!robots/crawler/spider, user agent) statement
?>

Here is a image tutorial to fake a Googlebot user agent with Chromium browser for testing the searchrobot/webcrawler/spider rule.

Googlebot User Agent Chromium Webmaster Tools
Support Penultima.de
PayPal Gefällt Mir Button
© Penultima.de - All rights reserved. Data protection statement & Imprint & Contact
Cookies in use.
More Infos