You can use the WebCookieManager for this.
As an example, you can add a method to your WebSession, called “CookiesAccepted”, with a Boolean return type. Inside, you can use something like this:
// If the cookie exists, and isn't empty, we'll consider the user accepted them. Return Cookies.Value("cookies_accepted").Trim <> ""
Now, in order to display the message, you can use a WebDialog, where your legal message will appear. Let’s call it CookiesWebDialog. Inside, place your legal text in a WebLabel, a default WebButton saying “Accept” (just close the WebDialog in its Pressed event) and maybe a WebLink to your dedicated Privacy WebPage.
Add a Dismissed event handler to your CookiesWebDialog with this code:
Var value As String = DateTime.Now.SecondsFrom1970.ToString("#") Var expiration As DateTime = DateTime.Now.AddInterval(0, 1) // The cookie will expire in one month. Adjust as needed. Session.Cookies.Set("cookies_accepted", value, expiration)
Now you just need to display your CookiesWebDialog, if the user didn’t accept them before. In your Session.Opening event handler, add this code:
If Not Session.CookiesAccepted Then Var dialog As New CookiesWebDialog dialog.Show End If
That should do the trick, but please adjust the example to adapt it to your country privacy laws.
I wrote a plugin for that a while ago. Nothing fancy, was just a prototype and I am not sure if it will still run on the latest release. Should give you an idea though to make it fully GDPR compliant.
Thanks for this Ricardo, points me in the right direction! Kind regards.
Hi Jeannot, thanks for this, no idea why I didn’t find this when doing various searches - I’ll try my own implementation based on above, if that doesn’t yield results, I’ll give yours a ago - kind regards, Dave.