HI
I have tried that and it gives meunexpected result like earlier.
The problem is when I run the script in browser and refresh it say for 17 times this is the status ->
This page points at a session (68618fc2f7cbdbcb6c3df05bc580ac79 )
count = 17.
start = 1050603546.
This session has lasted 17 seconds.
And then I have the new instance of the browser(i click on internet explorer) and paste the url of the same script in the address bar of newly opened browser window(Note I have not closed the window where count =17) then it runs a new session in new instance of browser ->
This page points at a session (1976b0e38186ae92c188366358e167af )
count = 0.
start = 1050603769.
This session has lasted 0 seconds.
Now I have two browser windows with 2 seperate sessions, count=17 and count=0, why I do not have the single session. Why when I have the 2nd instance of the browser run with the same URL the http request does not have the PHPSESSID info included in that, and as the http request from the 2nd browser request does not include the cookie info that is set by the first session, so I believe that is why it creates a new session. I want that the same session to be carried on , Can you please explain me why The 2nd browser instance can not use the session info that has been operationl due to the earlier (Browser 1 ) request and how I can redress it.
Thanks a lot
FOLLOWING IS THE CODE
<?php
// Initialize a session. This call either creates
// a new session or re-establishes an existing one.
session_start();
// If this is a new session, then the variable
// $count will not be registered
if (!isset($_SESSION['count']) )
{
// You don't need to register the variables using the new way
$SESSION["count"] = 0;
$SESSION["start"] = time();
}
else
{
$_SESSION["count"]++;
}
$sessionId = session_id();
?>
<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.0 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd" >
<html>
<head>
<title>Session State Test</title>
</head>
<body>
<p>This page points at a session
(<?php echo $sessionId; ?> )
<br>count = <?php echo $SESSION["count"];?>.
<br>start = <?php echo $SESSION["start"];?>.
<p>This session has lasted
<?php
$duration = time() - $_SESSION["start"];
echo "$duration";
?>
seconds.
</body>
</html>