For creating session first you need to start the session by using below code
session_start();
Then using $_SESSION
we can create a session variable.
Example Code:
<?php
session_start();
// store session data
$_SESSION['views']=1;
?>
<html>
<body>
<?php
//retrieve session data
echo "Pageviews=". $_SESSION['views'];
?>
</body>
</html>
More Reference visit -> http://www.w3schools.com/php/php_sessions.asp