PHP/Cookie Session/Session Variables Create
Create session variable
<?php
session_start();
$_SESSION["username"] = "Joe";
echo "Your username is ".$_SESSION["username"].".";
?>
Initiate session and create a few session variables
<?php
// Initiate session and create a few session variables
session_start();
// Set the variables. These could be set via an HTML form, for example.
$_SESSION["username"] = "joe";
$_SESSION["loggedon"] = date("M d Y H:i:s");
// Encode all session data into a single string and return the result
$sessionVars = session_encode();
echo $sessionVars;
?>