$_SESSION variable

The $_SESSION variables contains information regarding all session variables. Registering session information allows you the convenience of referring to it throughout your entire Web site, without the hassle of explicitly passing the data via GET or POST.

Session Syntax

session_start();

PHP Storing a Session Variable:

The following example first line set session_start function which is used to starting session . in the Second Line Total Page views assigned to $_SESSION variables.


<?php
session_start();
$_SESSION['page_views'] = 100; // store session data
?>

PHP Retrieve a Session Value:

Here get Total page View from above Example.

echo "Total Page views = ". $_SESSION[''page_views']; //retrieve data




Content