SXA Privacy Warning Cookie Expiration
The Privacy Warning component in SXA provides an easy way to display a cookie/privacy warning banner on a website:
Out of the box, the Privacy Warning provides all the functionality necessary to be GDPR compliant.
Once a user dismisses or accepts the banner, a cookie is set in their browser to acknowledge the selection for a certain period of time. By default, this
privacy-notificaion cookie is set to expire after 365 days, meaning the user won't see the message again for one year (or until they clear their cookies).
If you wish to change this default value (as of SXA 1.8.1), the expiration is hardcoded in the Privacy Warning view, located at
<webroot>/Views/Privacy Warning/PrivacyWarning.cshtml. The actual cookie is set with this line of code in several places throughout the view:
XA.cookies.createCookie('privacy-notification', 1, 365);
Your best bet for modifying this component is to clone it and modify as needed. However, be mindful that the author-facing configuration for this item is built into SXA via a Settings item, located in Sitecore at
/sitecore/content/Main/<tenant>/<site>/Settings/Privacy Warning, and will need to be extended or replaced with your own implementation.
Do you have questions, comments, or corrections for this post? Find me on Twitter: @BrandonMBruno