I Googled it but I can't seem to find an example code to implement cookie notification for first-time visits of my website (prompt that shows the site uses cookies).
How can I implement one in Spring MVC (easy and clean way)?
I Googled it but I can't seem to find an example code to implement cookie notification for first-time visits of my website (prompt that shows the site uses cookies).
How can I implement one in Spring MVC (easy and clean way)?
Depending on your use case, you might have different solutions. For instance :
Easy solution is using the LocalStorage to store the consent. Have a look at this answer for an exemple on how to use it.
Advantages : Easy to implement. No server code required.
Inconvenients : Requires that the client uses a compatible browser. You might want to test if the window.localStorage
is present. Also you can ignore old browser and always display the popup for these.
Hard option is to send to your server the consent, the server then stores the user ip address for example along with consent. Next time, the user visits your website, the consent is fetched to see if user let you store cookies.
Finally you could tune the hard option using the user login if the user has logged on your website so that the consent is saved across devices.