Session problems w/new functions
| From: | rfeather | Date: | Sat, 31 Jul 1999 07:20:22 +0000 |
| Subject: | Session problems w/new functions | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-3003@lists.php.net to get a copy of this message | ||
I've been playing with the new session management functions and, coming
from an ASP world, I'm confused about session management in the beta.
Here's the code I initialize the session with:
<?
session_start();
?>
<body bgcolor=#ffffff>
<?
function passSessionValues()
{
print("session_save_path: ".session_save_path()."<br>");
print("session_module_name: ".session_module_name()."<br>");
print("session_id: ".session_id()."<br>");
session_register("username");
session_register("email");
session_register("strDate");
global $username, $email;
$username = "Rich";
$email = "rfeather@originint.com";
}
function setValues()
{
$thisSession = session_encode();
print("encode: ".$thisSession."<br>");
}
passSessionValues();
setValues();
?>
</body>
</html>
and it produces what I'd expect:
session_save_path: /tmp
session_module_name: files
session_id: e7f903b2dbc78a88b8f97cc4c1a7e9d4
encode:
username|s:4:"Rich";email|s:22:"rfeather@originint.com";!strDate|
Now, under the same session, I run the following from a different page:
<?
session_start();
function callSessionData()
{
print("Session ID is ".session_id()."<br>");
print("Username is ".$username."<br>");
print("Email is ".$email."<br>");
print("Date is ".$strDate."<p>");
}
callSessionData();
?>
but it returns only:
Session ID is e7f903b2dbc78a88b8f97cc4c1a7e9d4
Username is
Email is
Date is
I've tried various combinations (e.g., creating global variables,
reinitializing the variable names, not encoding $thisSession ), but I
can't return the values for username, email, strDate in the subsequent
pages.
The only way I can figure to work with this is to schlepp the encoded
string into MySQL and retrieve it, decode it and then use it which seems
rather ungainly and not much easier than before.
Am I missing something with the new functions?
Thanks.