Browser cookies were born out of the desire to implement shopping carts online. Prior to the advent of cookies, web sites did not have features that allowed for session-based interactions between a client user and the server.
Cookies are not programs. Rather, they work in a similar fashion as how music programs use mp3’s. The file of a cookie is little more than a set of identification codes and tags for things like which user is accessing the website, what level of security clearance is required for a current session (i.e. should this user be required to log-in again or should secure browsing be used), and other pieces of information necessary for keeping a website in the same state it was as the last time it was used. A browser will make cookies on a per-website basis.
Cookies are saved on a user’s computer and are typically given a designated, short lifespan. Though there has been legislation passed in the way of requiring user clarity to a web site’s cookie policies, most cookies do not serve as tools for data mining being that they are saved on a user’s computer and not on servers that are property of the web site.