CodeIgniter Forums
Adding data to a session - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Adding data to a session (/showthread.php?tid=31474)



Adding data to a session - El Forum - 06-21-2010

[eluser]elmne[/eluser]
If i have different sets of data that i want to add to a session, is this the correct way to do it?

Code:
$option_data = array(
'item_id' => '',
'quantity' => ''
);
$this->session->set_userdata($option_data);


$person_data = array(
'firstname' => '',
'middlename' => '',
'surname' => ''
);
$this->session->set_userdata($person_data);


As this line

Code:
$this->session->set_userdata($person_data);

Seems different from the Hybrid session's format of

Code:
$this->session->set_userdata($newdata = array(), $newval = '');


And what's the limit to the data amount that can be added to a session?


Adding data to a session - El Forum - 06-21-2010

[eluser]WanWizard[/eluser]
Check the manual, the parameters of the set_userdata() method are described in there.

The limit depends on what you use for storage. Session variables are stored as a serialized array. If you use cookies, the max. size is 4Kb. For database storage, it depends on the definition of the 'session_data' field (in MySQL, a 'text' field can hold 2^16 bytes). For Native sessions, it depends on the amount of disk space you have available...