Tedd's SESSION Array Demo (Page 1)

   Array
(
    [name] => Tedd
    [phone] => 123-456-7890
    [count] => 0
)
    


GOTO Page 2

Please note -- There is NO FORM (i.e., no POST nor GET) on this page, but this script is populating variables and passing those variables from this page to another page via a SESSION array. Also note the count variable is being declared by a SESSION ternary operator.

This process demonstrates how variables can be passed from one page to another via a SESSION array.

 

CODE FOLLOWS

<?php
    session_name
("sperlt");
    
session_start();

    include(
'includes/header.php');

    
error_reporting(E_ALL);    // set error reporting to all

    // populate variables
    
$name 'Tedd';
    
$phone '123-456-7890';
    
$count = isset($_SESSION['count']) ? $_SESSION['count'] : 0;

    
// place the variables in an array
    
$a = array();
    
$a['name'] = $name;
    
$a['phone'] = $phone;
    
$a['count'] = $count;

    
// place the array in a SESSION
    
$_SESSION $a;

?>


    <h1>Tedd's SESSION Array Demo (Page 1)</h1>

    <pre>
   <?php
       print_r
($_SESSION);
   
?>
    </pre>

    <br>
    <br>
    <a href="session-array-page2.php">GOTO Page 2</a>

    <p>
        Please note -- There is NO FORM (i.e., no POST nor GET) on this page, but this
        script is populating variables and passing those variables from this page to
        another page via a SESSION array. Also note the count variable is being declared
        by a SESSION ternary operator.
    </p>

    <p>
        This process demonstrates how variables can be passed from one page to another
        via a SESSION array.
    </p>

<?php
    
include('includes/footer.php');
?>