Sessions
Sessions, which were integrated into PHP in version 4 of the language, are a means to store and track data for a user while they travel through a series of pages, or page iterations, on your site.
Session data is stored on the server , unlike cookies, stored on client's machine . Therefore sessions are secure whilst cookies can be easily altered , and no information is
exchanged between client and server so it can't be intercepted.
Sessions in PHP are started by using the session_start( ) function. The session_start( ) function must come before any HTML, including blank lines, on the page. It will look like this:
<?php
session_start( );
?>
<html>
<head> ....... etc
The session_start( ) function generates a random Session Id.Having established a session, you can now create, store and retrieve information pertaining to that session. You might want, for example, to keep track of items in your visitor's shopping cart. Information for sessions is stored in a special directory on the server; the path of that directory is specified in the server's PHP configuration files.
Information to be stored for a session is kept in session variables. Session variables are created by registering them for the session, using the session_register( ) function. To use that information (on any page iteration in the session) you simply reference the variable just like you would any other variable.