homepage Welcome to WebmasterWorld Guest from 50.16.165.62
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
Problem with using HTTP Session2
HTTP_Session2 is not storing session data in the database
stivare




msg:3904457
 10:06 pm on Apr 30, 2009 (gmt 0)

Hi,

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.

 

stivare




msg:3904508
 11:06 pm on Apr 30, 2009 (gmt 0)

To continue with the previous post... I redirect users to a different page on the same server once I store their username. I have written following vanilla code.

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

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved