Forum Moderators: coopster
I am just learning PHP and having trouble storing session data in the database.
I have a table "sessiondata" as follows
Id char(32)
Expiry int(11)
Data varchar(50)
and relevant code is as follows.
HTTP_Session2::useTransSID(FALSE);
HTTP_Session2::useCookies(TRUE);
HTTP_Session2::setContainer('MDB2',
array ('dsn' => &$mdb2, 'table' => 'sessiondata'));
HTTP_Session2::start('ssssssss');
$expireTime = time() + 60;
$idleTime = time() + 30;
HTTP_Session2::setExpire($expireTime);
HTTP_Session2::setIdle($idleTime);
HTTP_Session2::set('username', $userName);
print_r($_SESSION);
At this point the output looks like
Array ( [__HTTP_Session2_Info] => 1 [__HTTP_Session2_Expire] => 1241128863 [__HTTP_Session2_Expire_TS] => 1241128803 [__HTTP_Session2_Idle] => 1241128833 [__HTTP_Session2_Idle_TS] => 1241128803 [username] => team1 )
This part of the script wrote some values to the database once. Which got deleted when I had to repopulate the database. Now it is not populating that value again.
Any inputs will be greatly appreciated.
Thanks
Su
P.S.> one more thing. I have just picked up the examples from PEAR website documentation and trying it.
if (HTTP_Session2::isExpired()) {
echo "Session expired <BR>";
} elseif (HTTP_Session2::isIdle()) {
echo "Session was idle for too long <BR>";
} else {
echo "Session is still valid <BR>";
var_dump($_SESSION);
// $user = HTTP_Session2::get('username');
// echo "Welcome ".$user.". Have a great day. <BR>";
// HTTP_Session2::regenerateId();
}
At this poing I will get the "Session is still valid" message however the print_r statement gives NULL.
Please help me sort this thing out.
Thanks
Su