Instantly share code, notes, and snippets.

@pstaender /Page.ss
Last active Jan 15, 2017

Embed
What would you like to do?
Insert a Cookie Disclosure in SilverStripe / Einfügen eines Cookies Hinweises in SilverStripe
<% 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 %>
<?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