What is behind the sudden "Accept Cookies" notification on Web sites?

Cookies have been around for decades, and honestly, I think at least 90% of all people on the internet have no clue how they work. So why, just in the last few years, does almost every Web site I go to now have a "Cookie Notice" that I have to accept? A "Cookie Notice" wasn't necessary for the first 20+ years they have existed, so what's the deal? Is this related to the General Data Protection Regulation (GDPR)?