...

View Full Version : sessions in php



imran.rajani
03-04-2010, 02:47 AM
I was trying to append some values in already exists session.


if(isset($_SESSION['ems_id']) == NULL) {
echo "empty";
$_SESSION['ems_id'] = "0";
$_SESSION['ems_amt'] = "0";
}

$ix = count($_SESSION['ems_id']);
$ix++;

$_SESSION['ems_id'][5] = strval($rowEms['hs_id']);
$_SESSION['ems_amt'][5] = strval($rowBuy2['hs_ems']);


Its not working :(
Session stores new data but not populates - Just replacing.

whizard
03-04-2010, 03:15 AM
its replacing the value because you've hard-coded the slot in the array where you're storing the information.

$_SESSION['ems_id'][5] = strval($rowEms['hs_id']);
$_SESSION['ems_amt'][5] = strval($rowBuy2['hs_ems']);

will always store the info in the same place, thereby overwriting whatever was stored there before.

Dan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum