How can I save a string in the session in my php server version 4.0.6? I can not use database for the request of my client.
That is why I have to use session to store data.
Since $SESSION["str"] , $REQUEST["str"] cannot be used in php 4.0.6, $HTTP_SESSION_VARS was tried, but still not work.
It looks like the session variable never is really saved. I cannot find the session once I go to another page.
Thanks very much
😕
Code list as follows:
[code=php]
page1.php
<?
session_start();
//I got "parse error", why?
if( isset($HTTP_SESSION_VARS['id']) ){
$s = $HTTP_SESSION_VARS['id']); //error occur here
}
else{
$HTTP_SESSION_VARS['id'] = "some string";
}
echo "$HTTP_SESSION_VARS['id']"; // O.K. here
//I can retrieve my session variable "id" here.
?>
===============
page2.php
<?
session_start();
if( isset($HTTP_SESSION_VARS['id']) ){
echo "read session(id) success";
}
else{
echo "session(id) not found";
}
//Always got "not found" info.
//Why I lost my session variable after I navigated from page1.php to page2.php ?
?>
[/code]