Thursday, December 16, 2010

Session

<?php
// STARTING A SESSION
session_start();

// STORING A SESSION
if(isset($_SESSION['views'])) {
    $_SESSION['views']=$_SESSION['views']+1;
    $_SESSION['age']=20;
    $_SESSION['name']="Nathan";
}
else {
    $_SESSION['views']=1;
    $_SESSION['age']=23;
    $_SESSION['name']="Nanthan";
}

// RETRIEVING A SESSION
echo "Views=". $_SESSION['views'] . "<br>";
echo "Name=". $_SESSION['name'] . "<br>";
echo "Ages=". $_SESSION['age'] . "<br>";

// DESTROYING A SESSION
session_destroy();
?>

No comments:

Post a Comment