Cookies have been used by websites for a very long time. Cookies have not changed but the law has. On 26th May 2011 the New EU cookie law (e-Privacy Directive) was introduced. The changes and the required implementation were confusing enough for the UK's Information Commissioners Office to allow a further year for compliance. It is now a legal requirement!
A Cookie refers to a small text based file and its contents. These files are used to provide a sort of memory to the website. Websites deliver HTML or other HTML based pages to the users' computer. HTML is stateless and has no memory. That is, you request the page and it is sent and no connection is maintained between the website and the browser on your computer.
A cookie may simply record that this is your first visit to the website you are looking at. The next time you visit it might change the data to reflect the you are a returing visitor. Products such as Google Analytics do this (and much more). Many websites use Google Analytics to learn more about visitors to their website.
When you visit a website your browser sends some standard information to the website such as the browser (IE, Firefox, Chrome etc), the operating system (such as Windows 7, Linux etc) and screen resolution. It also sends the cookie information which the website can read and act upon before serving the web page. On your first visit to the website you may be asked for your name and preferred language. This information would be stored in the cookies and on subsequent visits this would allow the site to welcome you by name and serve pages in the language of your choice.
The cookie that many people are aware of is known as a Persistent Cookie. This type of cookie is stored on the computer's hard disk. It is very simple in structure and contains a name, some data and amongst other things an expiry date. This is the sort of cookie that might remember your name and preferred language to enhance your user experience when you next visit the site.
The Session Cookie is less well known and it expires when you leave the site. The Session Cookie is inititiated on the server and it places a cookie called PHPSESSID with a unique 32 digit hexadecimal number. As different pages from the same site are loaded the session cookie is sent to the server and as the server provided the cookie the server is aware that this is an existing user and it can continue from a previous page. In effect, the stateless HTML is given a link between browser and server.
A first party cookie is a cookie that is placed on the computer by the site the visitor is visiting.
A third party cookie is a cookie that is placed on the computer by a third party. There are a number of third parties who may wish to place cookies on a users computer such as Google when they are collecting generic statistics for their Analytics product.