This post is from 2019, it may be out-of-date. For a better solution try: Cookie Script for GDPR

Simple no-nonsense JavaScript and CSS cookie pop-up notification for legacy websites. Required jQuery.