Cookie Manager

Hello Will,

I looked at your Cookie Manager demo project and very much appreciated your many comments regarding cookie management even beyond what’s written on the S4S page, thank you.

However, I have two questions, which I want to post here for everyones’s benefit (I admit I didn’t test it out …):

  1. I wonder whether there is a small logical flaw with the examples of using only the ‘allow_cookies’ cookie with ‘true’ setting and only creating or deleting this cookie. For example, somebody wanting to opt out of non-essential cookies would have the cookie deleted, but then be bothered on every page again to possibly allow non-essential cookies again …

    Would the solution be to use the ‘allow_cookies’ cookie with e.g. a ‘false’ value ? It seems that the cookie manager possibly allows to modify a cookie. And a nested combination of the stack could test on the existence of either version of the content of the cookie, and only bother the user, if the cookie isn’t there at all. Would love to hear your take on it.

  2. I am using RWML on my websites, is there any interference with the ‘cookie manager’ stack. I presume as long as I don’t pack everything into the ‘false’ part of the stack it should work just fine independent of the ‘allow_cookies’ cookie, correct ?

Thanks

I had the chance to play around with the stack. Unfortunately, the conditional test is only for the existence of the cookie or any value different from zero (as described in the stack), but doesn’t include the specific value. Unless there is a way to test for the existence AND a specific value, it doesn’t seem to be possible to achieve the desired behaviour with one cookie only.

After a bit more exploration I found a solution. Using two cookies and the option to modify multiple cookies at once, the desired behaviour of recognising an ‘Opt-out’ works well. I used a ‘Privacy’ cookie to store, whether the user already made a decision, and a ‘NonEssential_Cookies’ for noting the user’s decision. Showing the e.g. ‘Alert Bar’ is then conditioned by the ‘Privacy’ cookie.

If the user opts into non-essential cookies, the following code sets both cookies accordingly, such the alert bar disappears and the decision is recorded:

$.cookie('NonEssential_Cookies', 'true', { expires: 40320, path: '/' });
$.cookie('Privacy_Cookie', 'true', { expires: 40320, path: '/' });

If the user opts out of non-essential cookies, the following code sets the ‘Privacy’ and deletes the ‘NonEssential’ cookie:

$.cookie('NonEssential_Cookies', 0, { expires: 0, path: '/' });
$.cookie('Privacy_Cookie', 'true', { expires: 40320, path: '/' });

Thank you again for this powerful stack, it essentially allows us RW users full control over cookies, and react to their existence.