Home Tutorial Php List PHP list all session variables

 
 

Share on Google+Share on Google+
PHP list all session variables
Posted on: October 31, 2009 at 12:00 AM
Advertisement
In this part of the tutorial we will learn how to get all session variable and its values. And we will also see the example related to the session.

  • All session variables and its values are maintained by the the super global variable $_SESSION.
  • $_SESSION is an associative array. It keeps the session data in key and value form.
  • session_start() starts the session.
  • After execution of the php file variable names and values gets stored in the session.


Example of PHP List All Session Variables

session1.php
<?php

    session_start();
    $roll
=1;
    $name
="jack";
    $subject
="computer science";
    session_register($roll);
    session_register($name);
    session_register($subject);
?>

session2.php
<?php
    session_start();
    foreach ($_SESSION as $key=>$val)
    echo $key." ".$val;
?>

first run session1.php
then run session2.php

Output

1 jack computer science

Advertisement

Related Tags for PHP list all session variables:


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: October 31, 2009

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com