What is a session?!?
A session is the name for a unique visit to a given webserver by a particular end user, and can be tracked by the webserver using a 32-bit hexadecimal string. Note that a unique visit is tracked thus:
What would we use a session for?
Sessions are most useful when you want to track specific information across multiple pages for a given end user's visit to your site. For instance, if you wanted to have a shopping cart type experience, or to track what a logged in user was doing for a given site - or even to control what parts of a website a given user can visit, as well as control what they can and cannot do on each page.
So how do we use these sessions?
In order to start and carry a session for a given page, we will need to initiate the session first on every page that we want to have the session continue on. We do that by starting off all stand-alone files (as opposed to included files) with the same lines of code:
The reason that I say that PHP included files don't count is because by trying to start sessions at the top of these files, you in effect try and start sessions twice (which won't work). Also note that you must start your session FIRST on the page - you may not output any text or headers to the browser, or your session will fail (and toss up an error).
Next stop - the MySQL tables!