Last Updated on: Saturday, April 4, 2009 8:59 PM

WDS 6 - Sessions and Cookies

A cookie is a small file stored on the client computer when visiting a website. Usually they are used to track visitor usage and habits. Since these files are stored on the client computers and collect information that they are told to collect by the developer people view them as a possible threat. Here is a list of some of their features and advantages:

Disadvangates

A session can be thought of a server-side cookie. It is a file stored on the server when visiting a website. A file is also stored on the client computer but it is only a small file that only references a 32 hexadecimal key called a session id. Here are the features and advantages of sessions:

Disavantages:

Depending on what you want to do with information collected from users and passed from page to page tells you which one to use. Cookies are disabled by many people who fear the security risks that can come from cookies. Developers are also worried about cookies because they can be modified by the client before they are resent with the server. Sessions provide the extra security for both client and the developers. Below is a diagram on how the process works with setting cookies. database table picture

Below is a list of code on how a session works. In the example below variables are posted into session variables then in the next PHP script they are being put into local variables again.