CodeIgniter Forums
session bug? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Discussion (https://forum.codeigniter.com/forum-31.html)
+--- Thread: session bug? (/thread-66727.html)



session bug? - startbbs - 11-25-2016

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?


RE: session bug? - prezire - 11-25-2016

(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');


RE: session bug? - startbbs - 11-25-2016

please check:
https://bcit-ci.github.io/CodeIgniter4/libraries/sessions.html#adding-session-data

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


RE: session bug? - prezire - 11-25-2016

(11-25-2016, 08:10 AM)startbbs Wrote: please check:
https://bcit-ci.github.io/CodeIgniter4/libraries/sessions.html#adding-session-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.


RE: session bug? - Avenirer - 11-25-2016

Isn't this thread the same as this one: http://forum.codeigniter.com/thread-66651.html ?... which was also started by you...


RE: session bug? - ciadmin - 11-25-2016

Duplicate thread!