JavaTechie

Its all about Technology

PHP- session Example June 3, 2009

Filed under: PHP — javatechie @ 12:33 pm

<?php
// Initialize the session.
session_start();
//store values
$_SESSION['favcolor'] = 'green';
$_SESSION['animal']   = 'cat';
$_SESSION['time']     = time();

//print stored values

echo $_SESSION['favcolor']; // green
echo $_SESSION['animal']; // cat
echo date('Y m d H:i:s', $_SESSION['time']);

// Unset all of the session variables.
$_SESSION = array();

// Finally, destroy the session.
session_destroy();

?>

 

One Response to “PHP- session Example”

  1. Real Chennai Says:

    Thanks yaar, thats useful for me. Am a asp programmer now want to shift to php. do u know any best pdf/website for beginners? or if u have any pdf for php pls mail me. Thanks in advance!


Leave a Reply