Problems, need help? Have a tip or advice? Post it here.
3 posts Page 1 of 1
I´m having a problem with my cookie system. I need to display a warning message from the first time the user comes to my place to the moment he clicks a link.

When the user clicks the link, a javascript is triggered and a cookie "cookies_rilova" is installed, with the valour "aceptada".

The message is only displayed when the cookie hasn´t the value "aceptada"

The javascript part is ok, and when I check the cookies history in my browser, the cookie is installed with the valor "aceptada", for a week period.

My problem is that sometimes, within the week period, the message is displayed again, when should´t.

This is the message part of code

Code: Select all
<cms:set cookie_aceptada="<cms:get_cookie 'cookies_rilova' />" /> <cms:if cookie_aceptada !='aceptada'> <div id="overbox3"> <div id="infobox3"> <div class="container"><div class="row"><div class="col-xs-12"> <p>Esta web utiliza cookies propias y de terceros para mejorar sus servicios. Si continua navegando, consideramos que acepta su uso. Puede cambiar la configuración u obtener más información <a href="<cms:link masterpage='cookies.php' />">aquí</a>.</p> <a onclick="aceptar_cookies()" style="cursor:pointer" class="cookie-close"><i class="small mdi-action-highlight-remove"></i></a> </div></div></div> </div> </div> </cms:if> 


Any tips??
Hi,

The code you posted simply checks for the cookie and acts accordingly.
So if the message does get displayed, it can only mean that the cookie with that value was indeed not found.

My problem is that sometimes, within the week period, the message is displayed again, when should´t.
"When it shouldn't" would mean that the cookie was present and yet the message was displayed. I doubt if this is the case. I wonder if you have checked at the moment the message is displayed if the cookie is present or not?

Cookie management is at the client's browser end. The client (or the browser) can choose to delete the cookies before the set period (one week in your case) is over. Perhaps this could be a reason?
@cheesypoof just suggested that perhaps caching could be a reason.
It very well might be so if you are using Couch's caching, please put a <cms:no_cache /> statement somewhere at the top of the problem template.

As an alternative, if possible you can use JS to check for the cookie and display the message. This way caching won't be a factor.
3 posts Page 1 of 1