Session

From Help system
Jump to: navigation, search
<?php
session_register ("count");
$HTTP_SESSION_VARS["count"]++;
?>
Registered session variable "count".
Now go to next <a href="2.php?<?php=SID?>">page</a> to check it.
<?php
session_start();
echo "You had visited this page ".$HTTP_SESSION_VARS["count"]++." times. Try to reload page!";
?>


<?php
session_start();
echo 'Welcome to page #1';
$_SESSION['favcolor'] = 'green';
$_SESSION['animal']   = 'cat';
$_SESSION['time']     = time();
// Works if session cookie was accepted
echo '
<a href="page2.php">page 2</a>'; // Or maybe pass along the session id, if needed echo '
<a href="page2.php?' . SID . '">page 2</a>'; ?>


<?php
session_start();
echo 'Welcome to page #2
'; echo $_SESSION['favcolor']; // green echo $_SESSION['animal']; // cat echo date('Y m d H:i:s', $_SESSION['time']); // You may want to use SID here, like we did in page1.php echo '
<a href="page1.php">page 1</a>'; ?>
Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox