Page 1 of 3
2.0.1: Cookie problem
Posted: Sun Oct 04, 2015 6:49 pm
by pschoenb
Hello,
since the upgrade to 2.0.1, the first line in the following code
Code: Select all
{if empty($smarty.cookies.cookie_consent)}
<!-- Begin EU cookie consent (HTML) -->
<div id="cookie_consent">
{if $page_lang == 'de_DE'}
<p>Wir verwenden Cookies, um Ihnen auf unserer Webseite die bestmögliche Darstellung und Seitennutzung anbieten zu können.<br />
Wenn Sie unsere Webseite weiter nutzen, ohne Ihre Browsereinstellungen zu ändern, stimmen Sie sder Nutzung von Cookies auf dieser Webseite zu.<br />
<br />
<a class="accept_cookies">Fortsetzen</a><a href="datenschutz" target="_blank" class="more_info">Mehr Informationen...</a></p>
{else}
<p>We use cookies to ensure that we give you the best experience on our website.<br />
If you continue without changing your browser settings, we will assume that you are happy to receive all cookies on this website.<br />
<br />
<a class="accept_cookies">Continue</a><a href="privacy" target="_blank" class="more_info">More info...</a></p>
{/if}
</div>
<!-- End EU cookie consent (HTML) -->
{/if}
always returns true, even though the cookie exists and is not empty.
The cookie is set as follows:
Code: Select all
{literal}
<!-- Begin EU cookie consent (JQuery) -->
<__script__ type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></__script>
<__script__ type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></__script>
<__script__ type="text/javascript">
$(".accept_cookies").click(function () {
$("#cookie_consent").toggle("slow");
location.reload();
} );
$(document).ready(function() {
$.cookie("cookie_consent", "yes", { domain: "klangexzellenz.de", path: "/", expires: 1095 } );
} );
</__script>
<!-- End EU cookie consent (JQuery) -->
{/literal}
What could be wrong?
Re: 2.0.1: Cookie problem
Posted: Mon Oct 05, 2015 7:27 pm
by pschoenb
I just figured out that the problem seems to be that the overlay keeps reopening if I click "Continue". If I reload the page in the browser, though, the overlay disappears.
Re: 2.0.1: Cookie problem
Posted: Thu Oct 08, 2015 5:39 pm
by pschoenb
Does anyone have a clue about what goes wrong here?
Re: 2.0.1: Cookie problem
Posted: Thu Oct 08, 2015 6:19 pm
by velden
Code: Select all
<!-- Begin olark code -->
<__script__ data-cfasync="false" type='text/javascript'>
if ( $(window).width() > 768) {
...
Your calling above javascript BEFORE including jQuery library. Start fixing that and test again.
Re: 2.0.1: Cookie problem
Posted: Fri Oct 09, 2015 4:11 pm
by pschoenb
velden wrote:Code: Select all
<!-- Begin olark code -->
<__script__ data-cfasync="false" type='text/javascript'>
if ( $(window).width() > 768) {
...
Your calling above javascript BEFORE including jQuery library. Start fixing that and test again.
Now, I moved the JQuery stuff before any other Javascript stuff. Still the same.
Re: 2.0.1: Cookie problem
Posted: Sat Oct 10, 2015 11:05 am
by pschoenb
For completeness: This template code worked fine with CMSMS 2.0. What could have changed?
Re: 2.0.1: Cookie problem
Posted: Sat Oct 10, 2015 11:17 am
by Jo Morg
pschoenb wrote:For completeness: This template code worked fine with CMSMS 2.0. What could have changed?
Difficult to say without seeing the whole template. There most likely are issues with variable scopes, but it's impossible to tell without the full template logic...
Re: 2.0.1: Cookie problem
Posted: Sat Oct 10, 2015 5:16 pm
by pschoenb
Jo Morg wrote:pschoenb wrote:For completeness: This template code worked fine with CMSMS 2.0. What could have changed?
Difficult to say without seeing the whole template. There most likely are issues with variable scopes, but it's impossible to tell without the full template logic...
How do I check this? Could it be a problem that I wrapped all subparts into separate global conent blocks like this?
Code: Select all
{babel action="assign"}
{content block="metadescription" label="Beschreibung" oneline="true" assign="metadescription"}
{assign var='langcode' value={$lang|truncate:'2':''}}
<!DOCTYPE html>
<__html xml:lang="{$langcode}" lang="{$langcode}">
<head>
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css" rel="stylesheet">
{SEOTools2}
{metadata}
{cms_stylesheet}
</head>
</__body>
{global_content name='Cookie Consent HTML'}
{global_content name='Cookie Consent JQuery'}
{global_content name='Google Analytics'}
<div id="wrap" class="container-fluid">
<div id="header">
<img src="/images/elements/banner.jpg" alt="Klangexzellenz logo"/> </div>
<div class="row">
<div id="links" class="col-xs-12 col-sm-3">
<nav class="navbar navbar-default">
<div class="navbar-header">
<button type="button" class="navbar-toggle"
data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="collapse navbar-collapse">
<div id="babel">
{babel action="menu"}
</div>
<div id="avmenu">
{Navigator start_level="2"}
</div>
</div>
</nav>
</div>
<div id="content" class="col-xs-12 col-sm-6">
{content}
</div>
<div id="rechts" class="hidden-xs hidden-sm col-md-3">
<div id="news">
{global_content name='news'}
</div>
<div id="sharing">
{global_content name='sharing'}
</div>
<div id="social">
{global_content name='social'}
</div>
<div id="audiocation_zertifikat">
{global_content name='audiocation_zertifikat'}
</div>
<div id="berkleemusicmastering">
{global_content name='berkleemusic_mastering'}
</div>
<div id="drlogo">
{global_content name='drlogo'}
</div>
</div>
</div>
<div id="footer">
{global_content name='footer'}
</div>
</div>
{global_content name='Olark'}
{global_content name='Piwik'}
{global_content name='Bootstrap'}
<__body>
</__html>
Re: 2.0.1: Cookie problem
Posted: Sat Oct 10, 2015 5:45 pm
by pschoenb
Now, I've put the whole cookie consent stuff (HTML and JQuery) into a single global content block. But still, no change.
However, now I just notice that the cookie is no longer set. What could be the reason?
Re: 2.0.1: Cookie problem
Posted: Sat Oct 10, 2015 6:16 pm
by Jo Morg
Ok, if you have put the whole code into a self-contained template (and I assume that is what you are referring to when mentioning "a single global content block" since there are no content blocks in CMSMS 2.x) one way to debug this is to compare the HTML source produced by the original site against the one produced by cloned site. There must be differences. If not then there is always the possibility that the cookie consent plugin is not working properly with CMSMS 2.x... but that is, at this point, just an assumption...
Re: 2.0.1: Cookie problem
Posted: Sat Oct 10, 2015 8:11 pm
by Rolf
I havent upgraded a website that uses the cookie consent stuff. Will try tomorrow
Re: 2.0.1: Cookie problem
Posted: Sun Oct 11, 2015 10:10 am
by PinkElephant
pschoenb wrote:velden wrote:Your calling above javascript BEFORE including jQuery library. Start fixing that and test again.
Now, I moved the JQuery stuff before any other Javascript stuff.
Are you sure? If I'm looking in the right place, jquery is called after "$(window)" - twice, in fact - and the javascript error console shows "$ is not defined".
Re: 2.0.1: Cookie problem
Posted: Sun Oct 11, 2015 11:57 am
by Rolf
I tested both methods described at
http://www.cmscanbesimple.org/blog/add- ... ade-simple in a to 2.0.1.1 upgraded website.
Both work without any problem... You should have something not correct in your template or the way you implemented the tutorial
Re: 2.0.1: Cookie problem
Posted: Sun Oct 11, 2015 5:13 pm
by pschoenb
Ok, now, I have no JS errors anymore in the console, but still, the overlay keeps returning until I reload the page in the browser. Why?
I assume that the cookie gets set, but when the page is reloaded when clicking "Continue", the cookie is not yet present in
Could that be?
Re: 2.0.1: Cookie problem
Posted: Sun Oct 11, 2015 5:31 pm
by Rolf
The cookie *is* set at your website
Try to play with
Code: Select all
{if empty($smarty.cookies.cookie_consent)}
i.e.
Code: Select all
{if !isset($smarty.cookies.cookie_consent)}