At its core, a cookie is simply a text file stored locally on the visitor’s computer containing some small fragment of information. This information can be called by the site and used to return specific elements relative to the information contained within. Using .NET, or PHP, the like – a server can read the data stored within the cookie and deliver elements on the page based on the cookie itself.
For an example, I’ve recently begun testing various positions for a Facebook “Like” button on a site that’s currently live. I would like to determine what placement will drive the most “likes” to a Facebook profile. Fortunately, with the recent addition of the ability to track the “source” of a Like click by appending “fb_source=foo” to the parameters of the iFrame URL, this is fairly easy. I simply set a cookie to expire in a month with a value of either “sidebar”, “header”, “body”, or “footer”. Depending on the value of the cookie for each user, I place the Like button on the page making sure to attribute the source to the position it is currently located in. After a month, I view my statistics via Facebook to see which position had the most success. Based on that information, I can then permanently place the Like button in the area I know to have the highest click rate.