note 96532 deleted from session.examples by danbrown
| From: | danbrown@php.net | Date: | Wed, 03 Mar 2010 18:28:36 +0000 |
| Subject: | note 96532 deleted from session.examples by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-166594@lists.php.net to get a copy of this message | ||
Note Submitter: ragnar
----
That code does'nt work for me. I use this one instead:
<?php
// Get the private context
session_name('Private');
session_start();
$private_id = session_id();
if( !$b = $_SESSION['pr_key']){
$b=0;
}
session_write_close();
// Get the global context
session_name('Global');
session_id('TEST');
session_start();
if( !$a = $_SESSION['key']){
$a=0;
}
session_write_close();
// Work & modify the global & private context (be ware of changing the global context!)
?>
<html>
<body>
<h1>Test 2: Global Count is: <?php ++$a; echo $a; ?></h1>
<h1>Test 2: Your Count is: <?php ++$b; echo $b; ?></h1>
<h1>Private ID is <?php echo $private_id?></h1>
<h1>Gloabl ID is <?php echo session_id()?></h1>
<pre>
<?php print_r($_SESSION); ?>
</pre>
</body>
</html>
<?php
// Store it back
session_name('Private');
session_id($private_id);
session_start();
$_SESSION['pr_key'] = $b;
session_write_close();
session_name('Global');
session_id('TEST');
session_start();
$_SESSION['key']=$a;
session_write_close();
?>