I'm new to session id variables. I'm trying to write records containing the
session id to a log file but the session id keeps disappearing. I'm using
session_registe r() because the site has register_global s = On (Hosted web
site Php Version 4.3.3).
If I work on my local Windows XP computer and I start up a browser window
the first printf statement
printf ("This is the SID = $szTmp01<br>"); results in:
This is the SID =
Which is blank. The second print statement gives.
This is the session_id = PHPSESSID=9ebb9 5e5a3a68662c5ff 32c2db358222
which seems to work Ok.
When I execute the script on the hosted web site the result is:
This is the SID =
This is the session_id =
Can anyone explain what I'm doing wrong and why SID does not seem to have or
retain a value?
Thanks,
Doug
--------------------------------------------------
<?php
session_start() ;
error_reporting (E_ALL);
$szTmp01 = '';
$szTmp01 = SID;
printf ("This is the SID = $szTmp01<br>");
if(!session_is_ registered("ses sion_id"))
{
session_registe r("session_id") ;
}
$self_url = $_SERVER['PHP_SELF'];
if(IsSet($HTTP_ SESSION_VARS["session_id "]) &&
$HTTP_SESSION_V ARS["session_id "])
{
$session_id = $HTTP_SESSION_V ARS["session_id "];
$href = "$self_url?$szT mp01";
}
else
{
$session_id = SID;
session_registe r("session_id") ;
$href = $self_url;
}
printf ("This is the session_id = $session_id<br> ");
$MyVar = LogSession();
?>
<?php
function LogSession()
{
global $session_id;
global $self_url;
global $HTTP_SESSION_V ARS;
global $href;
if(!session_is_ registered('ses sion_id'))
{
$session_id = SID;
session_registe r('session_id') ;
}
$dtime = date('r');
$session_id = $HTTP_SESSION_V ARS["session_id "] ;
$rec_log = "Date: $dtime | SID: $session_id \n";
$fp = fopen("SLog/logs.txt", "a");
fputs($fp, $rec_log);
fclose($fp);
return;
}
?>
session id to a log file but the session id keeps disappearing. I'm using
session_registe r() because the site has register_global s = On (Hosted web
site Php Version 4.3.3).
If I work on my local Windows XP computer and I start up a browser window
the first printf statement
printf ("This is the SID = $szTmp01<br>"); results in:
This is the SID =
Which is blank. The second print statement gives.
This is the session_id = PHPSESSID=9ebb9 5e5a3a68662c5ff 32c2db358222
which seems to work Ok.
When I execute the script on the hosted web site the result is:
This is the SID =
This is the session_id =
Can anyone explain what I'm doing wrong and why SID does not seem to have or
retain a value?
Thanks,
Doug
--------------------------------------------------
<?php
session_start() ;
error_reporting (E_ALL);
$szTmp01 = '';
$szTmp01 = SID;
printf ("This is the SID = $szTmp01<br>");
if(!session_is_ registered("ses sion_id"))
{
session_registe r("session_id") ;
}
$self_url = $_SERVER['PHP_SELF'];
if(IsSet($HTTP_ SESSION_VARS["session_id "]) &&
$HTTP_SESSION_V ARS["session_id "])
{
$session_id = $HTTP_SESSION_V ARS["session_id "];
$href = "$self_url?$szT mp01";
}
else
{
$session_id = SID;
session_registe r("session_id") ;
$href = $self_url;
}
printf ("This is the session_id = $session_id<br> ");
$MyVar = LogSession();
?>
<?php
function LogSession()
{
global $session_id;
global $self_url;
global $HTTP_SESSION_V ARS;
global $href;
if(!session_is_ registered('ses sion_id'))
{
$session_id = SID;
session_registe r('session_id') ;
}
$dtime = date('r');
$session_id = $HTTP_SESSION_V ARS["session_id "] ;
$rec_log = "Date: $dtime | SID: $session_id \n";
$fp = fopen("SLog/logs.txt", "a");
fputs($fp, $rec_log);
fclose($fp);
return;
}
?>
Comment