Accessing Session Variables : Session Variables « Cookie Session « PHP






Accessing Session Variables

 
<?php
session_start();
?>
<html>
<head>
<title>Accessing Session Elements</title>
</head>
<body>
<div>
<h1>A Content Page</h1>
<?php
if ( is_array( $_SESSION['products'] ) ) {
  print "<b>Your cart:</b><ol>\n";
  foreach ( $_SESSION['products'] as $p ) {
    print "<li>$p</li>";
  }
  print "</ol>";
}
?>
<a href="indec.php">Back to product choice page</a>
</div>
</body>
</html>
  
  








Related examples in the same category

1.A session variable can be destroyed with a call to session_unregister().
2.Adding Session Data
3.Checking Session Data
4.Reading Session Data
5.Registering Variables with a Session
6.Registering an Array Variable with a Session
7.Storing Complex Data Types in Sessions
8.Storing Complex Data Types to session
9.Storing Simple Data Types in Sessions