<?php
    include("debuglib.php");
?>



<?php 

$cookieName = 'cname';
$cookieValue = 'cvalue';


$currentCookieParams = session_get_cookie_params(); 

$hostName = $_SERVER["SERVER_NAME"];
$hostNameArr = explode('.', $hostName);

$rootDomain = '';
for ($i = 1; $i < count($hostNameArr); $i++)
{
  $rootDomain .= '.' . $hostNameArr[$i];
}

//$rootDomain = '.engprod-charter.net'; 

session_set_cookie_params( 
    $currentCookieParams["lifetime"], 
    $currentCookieParams["path"], 
    $rootDomain, 
    $currentCookieParams["secure"], 
    $currentCookieParams["httponly"] 
    ); 


// Get the private context
session_name('atmail6');
session_start();

$private_id = session_id();
$b = $_SESSION['pr_key'];
setcookie($cookieName, $cookieValue, time() + 3600, '/', $rootDomain); 
session_write_close();
?>


<html>
    <body>
<!--        <h1>Test 2: Global Count is: <?=++$a?></h1> -->
        <h1>Test 2: Your Count is: <?=++$b?></h1>
        <hr />
        <h1>Private ID is <?=$private_id?></h1>
        <h1>Gloabl ID is <?=session_id()?></h1>
        <pre>
        <?php print_r($_SESSION); ?>
        </pre>
    </body>
</html>

<?php
// Store it back
session_name('atmail6');
session_id($private_id);
session_start();
$_SESSION['pr_key'] = $b;
session_write_close();
?>



<?php
show_vars();
?>
