Printing session data : _SESSION « Cookie Session « PHP






Printing session data

 
<?php
session_start();

$main_dishes = array('cuke' => 'A',
                     'stomach' => "B",
                     'abalone' => 'C');

if (count($_SESSION['order']) > 0) {
    print '<ul>';
    foreach ($_SESSION['order'] as $order) {
        $dish_name = $main_dishes[ $order['dish'] ];
        print "<li> $order[quantity] of $dish_name </li>";
    } 
    print "</ul>";
} else {
    print "You haven't ordered anything.";
}
?>
  
  








Related examples in the same category

1.Count Visits with session
2.Counting page accesses with a session
3.Implementing Sessions
4.Registering a variable by including it in $_SESSION
5.Session based counter
6.Session preferences
7.Session using the proper $_SESSION super global
8.Verifying session info
9.check for a valid login in sessions
10.create_session_variable.php
11.delete_session_variable.php
12.Doing something special for a logged in user
13.Setting Up Cookie Authentication