The short answer is Junkbusters, if you're using
a windows platform.
Go to
www.junkbusters.com.
They have lots of info on web security and privacy, but the gem is little freeware proxy application. It takes a wee bit o tinkering to set up, but once there can selectively block ads, cookies, and other items.
It's a proxy, so you configure your browser to look at the proxy, then configure the proxy to look at the internet.
I love it - I have it set to accept cookies from the various shopping sites and other legit sites I use, and reject all others.