Portal Engine Questions on portal engine and web parts.
Version 6.x > Portal Engine > Caching and a cookie law web part View modes: 
User avatar
Member
Member
Dlglsh - 9/18/2012 4:29:53 AM
   
Caching and a cookie law web part
Hi all,

I have created a web part and in the code behind for the control it looks for the existence of a cookie and it's value. If it finds the cookie and it contains the correct value the web part's visibility is set to false.

The issue is that the web part is being cached, so even if the cookie is there with the correct value the web part is being displayed.

How can I stop this happening? I've got [PartialCaching(0)] on my .ascx.cs file, I've set 'Partial cache minutes:' in the web part properties to 0. According to this page cookie macros cannot be used in the web part properties (and therefore visibility property).

My test development site doesn't have site caching like the live site and works perfectly. Does anyone have any suggestions (other than turning of site caching) of how to get around this issue?

Thanks in advance for your help as always!

Matt

User avatar
Member
Member
Dlglsh - 9/18/2012 6:12:36 AM
   
RE:Caching and a cookie law web part
I *may* have found a workaround, but can't test it on the live site until tomorrow. It's not the greatest but it may work...

Adding the following line to the 'Edit value' of 'Visible' in the web part properties seems to be returning 1 (true), therefore visible, if the cookie is not set, or the value of the cookie if it is set. I then just need to set the cookie level to 0 when someone accepts/hides the cookie message. The zero will then return as false and hide the web part.

{%Cookies.cmscookielevel|1%}'. I'm not sure why that is there or if it is indicating an error of some sort.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 9/18/2012 6:41:56 AM
   
RE:Caching and a cookie law web part
Hi,

Your workaround looks good. Let us know the results.

The # in the macro is the signature sue to the macro security. It is possible to turn it off.

Best regards,
Juraj Ondrus

User avatar
Member
Member
Dlglsh - 9/19/2012 2:14:32 AM
   
RE:Caching and a cookie law web part
Hi Juraj,

Live. Tested. Working. :)

Thanks,

Matt

User avatar
Member
Member
Dlglsh - 12/5/2012 5:36:43 AM
   
RE:Caching and a cookie law web part
Sorry to bring this topic up again, but had to shelve the Cookie law web part for a while due to more urgent projects.

It doesn't seem to matter what I do, I cannot stop the web part from caching. I was wondering if there was a fix in v6.0.57 or some way of getting around this issue!?

Thanks,

Matt

User avatar
Member
Member
Dlglsh - 9/20/2012 5:06:30 AM
   
RE:Caching and a cookie law web part
Just in case anyone stumbles across this thread and decides to implement a web part in the same way...

Setting cmscookielevel to 0 will play havoc with CMS Desk as it believes the user will not allow cookies - I should have seen that coming! Instead, I am setting the cmscookielevel cookie to 1000 (allow-all) and using the following code in the Visible > Edit input box:
{%Cookies.cmscookielevel|(notequals)1000%}

Matt