Last active
January 15, 2017 09:03
-
-
Save pstaender/e5ca1c25dcc111e2142f to your computer and use it in GitHub Desktop.
Insert a Cookie Disclosure in SilverStripe / Einfügen eines Cookies Hinweises in SilverStripe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<% if not CookieUsageConfirmed %> | |
<div id="desktop-cookie-disclosure" style="position: fixed; z-index: 10000; top: 0; left: 0; width: 100%;"> | |
<div onclick="$.ajax({ url: 'home/confirmCookieUsage', method: 'post' }); $(this).parent().fadeOut(300, function() { $(this).remove(); });" style="cursor: pointer; color: #fff; background: rgba(0,0,0,0.8); border-radius: 10px; padding: 2px 5px; position: absolute; top: 0.4em; right: 0.5em; font-size: 9px; line-height: 13px;">✖</div> | |
<div style="color: #fff; background: #666; padding: 0.5em 1em; font-size: 0.9em; text-align: center;"> | |
<span style="" lang="en"> | |
We have placed cookies on your computer to help make this website better. We use a Google Analytics script which sets cookies. More details can be found in our <a href="impressum/#cookies" style="color: #fff;">privacy policy</a> | |
</span> | |
<span style="display: none;" lang="de"> | |
Wir verwenden bei Ihrem Besuch auf unserer Webseite Cookies. Indem Sie unsere Webseite benutzen, stimmen Sie unseren Datenschutzrichtlinien zu. <a href="impressum/#cookies" style="color: #fff;">Mehr Informationen dazu</a></span> | |
</span> | |
</div> | |
</div> | |
<% end_if %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Page Controller | |
class Page_Controller extends ContentController { | |
private static $allowed_actions = [ | |
'confirmCookieUsage' => true, | |
]; | |
function confirmCookieUsage() { | |
if ($this->getRequest()->isPOST()) { | |
Cookie::set('CookieUsageConfirmed', true); | |
} | |
} | |
function CookieUsageConfirmed() { | |
return Cookie::get('CookieUsageConfirmed'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment