CodeIgniter Forums

Full Version: session bug?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I used session in many places.
when I set(update) part of session. the previous session data was destroied. only the updated data are available.

please test it!!
step one, use the follow data.

PHP Code:
$data = array(
 
       'userid'  => '1',
 
       'username'  => 'johndoe',
 
       'email'     => '[email protected]'
);

$session->set$data); 

step two, run the follow code to update part of data.
PHP Code:
$newdata = array(
 
       'username'  => 'david name',
);

$session->set($newdata); 

now the session data is array('username'=>'david name')
the session of email and userid are not available.

is it a bug?
(11-25-2016, 05:49 AM)startbbs Wrote: [ -> ]I used session in many places.
when I set(update) part of session. the previous session data was destroied. only the updated data are available.

please test it!!
step one, use the follow data.

PHP Code:
$data = array(
 
       'userid'  => '1',
 
       'username'  => 'johndoe',
 
       'email'     => '[email protected]'
);

$session->set$data); 

step two, run the follow code to update part of data.
PHP Code:
$newdata = array(
 
       'username'  => 'david name',
);

$session->set($newdata); 

now the session data is array('username'=>'david name')
the session of email and userid are not available.

is it a bug?

Shouldn't you be passing 2 params with the key and its value instead of array like set('username', 'david');
please check:
https://bcit-ci.github.io/CodeIgniter4/l...ssion-data

$session->set($array);is supported, 
(11-25-2016, 08:10 AM)startbbs Wrote: [ -> ]please check:
https://bcit-ci.github.io/CodeIgniter4/l...ssion-data

$session->set($array);is supported, 

Yes it is. But using an array as a single param, erases the previous values. Use the 2 param style when setting a single value.
Isn't this thread the same as this one: http://forum.codeigniter.com/thread-66651.html ?... which was also started by you...
Duplicate thread!