Session Example Page 1
The value (pulled from SESSION) for $var is 0The value for $var is 1
GOTO Page 2
<?php
session_name("sperlt");
session_start(); // establish, or continue, a session
include('../includes/header4.php');
echo('<h1>Session Example Page 1</h1>');
// pull the CURRENT value from the SESSION
$var = isset($_SESSION['var']) ? $_SESSION['var'] : 0;
// the second time into this page will show the SESSION value is not zero
// show the value pulled from the SESSION
echo("The value (pulled from SESSION) for \$var is $var <br><br>");
// assign 1 to the var
$var = 1;
// store the value of var in the SESSION['var'}
$_SESSION['var'] = $var;
// Note the value of $var
echo("The value for \$var is $var <br><br>");
echo('<a href="page-two.php">GOTO Page 2</a>');
include('../includes/footer4.php');
?>
Last modified: March 25 2022
Line Count: 28