PHP Classes

File: examples/session/example_basic.php

Recommend this page to a friend!
  Classes of Haseeb Ahmad Basil   PHP Skeleton Framework   examples/session/example_basic.php   Download  
File: examples/session/example_basic.php
Role: Example script
Content type: text/plain
Description: Example script
Class: PHP Skeleton Framework
Extensive Web application development framework
Author: By
Last change:
Date: 8 years ago
Size: 996 bytes
 

Contents

Class file image Download
<?php
error_reporting
(E_ALL);
require_once(
'config.php');
require_once(
'A/Session.php');

$session1 = new A_Session();
$counter = $session1->get('counter', 9);
$session1->set('counter', ++$counter);
?><html>
<body>
<?php
echo "Start counter with a default of 10, counter=$counter<br/>";
$session1->set('one.two', 'hi1');
$session1->set('one.three.six', 'hi2');
$session1->set('one.three.four', 'hi3');
$session1->set('one.five', 'hi4');

$session2 = new A_Session();
$counter = $session2->get('counter');
echo
"Is Singleton? Second session object counter=$counter<br/>";

if (
$session1 !== $session2) {
    echo
"session1 !== session2<br/>";
}
if (
$session1 == $session2) {
    echo
"session1 == session2<br/>";
}

?>
<p><a href="?destroy=">refresh</a> <a href="?destroy=yes">destroy</a></p>
<?php
echo '<pre>' . print_r($_SESSION, true) . '</pre>';

if (isset(
$_REQUEST['destroy']) && ($_REQUEST['destroy'] == 'yes')) {
   
$session1->destroy();
}
?>
</body>
</html>