Austin's SESSION Demo (Page 1)

This adds one to a variable and stores that value in a SESSION.

The following shows value in the SESSION.

Array
(
    [var] => 1
)

session_id() =


Code follows

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Session Page 1</title>
    <link rel="stylesheet" href="../css/styles.css">
</head>
<body>

<div class="page">

    <p class="nav"><a href="../../index.php">Home</a></p>

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

    
// code
    
error_reporting(E_ALL);    // set error reporting to all
    
$var = isset($_SESSION['var']) ? $_SESSION['var'] : 0;

    
$var++;
    
$_SESSION['var'] = $var;
    
?>
    <h1>Austin's SESSION Demo (Page 1)</h1>

    <p>
        This adds one to a variable and stores that value in a SESSION.
    </p>

    <p>
        The following shows value in the SESSION.
    </p>

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

    echo(
'<p>session_id() = ' . session_id() . '</p>');
    
?>
    <form action="session-page2.php" method="post">
        <input type="submit" value="GOTO Page 2">
    </form>

    <hr>

    <h2>Code follows</h2>

    <div class="code"><?php highlight_file(__FILE__); ?></div>

    <p class="nav nav-foot"><a href="../../index.php">Home</a></p>

</div>

</body>
</html>