Welcome Guest, Not a member yet? Register   Sign In
session set userdata, large multi-dimensional arrays
#1

[eluser]bonatoc[/eluser]
Hi,

Just posting this for newbies like me, I thought it might help.

I did not understand why a big multi-dimensional array would not be stored.
I was going crazy, because when doing a
Code:
// GOOGLE MAPS API FULL RESPONSE - BIG ARRAY
$this->session->set_userdata('latest_google_response', $latest_google_response);


// DEBUG ARRAY
echo("<br><b>session->userdata -></b><pre>");
print_r($this->session->userdata);
echo("</font></pre><br>");
exit;

... the big array showed up !
So I assumed the big array was correctly stored into userdata.

But then, when checking on other controller/views, $this->session->userdata was NOT containing 'latest_google_response'.

When you're using ci sessions relying only on cookies, It seems in fact that the 4KB limit is pretty easy to bump into.

Using ci sessions relying on database solved it.
Here's what I use on :
application/config/config.php :

Code:
|--------------------------------------------------------------------------
| Session Variables
|--------------------------------------------------------------------------
|
| 'session_cookie_name' = the name you want for the cookie
| 'encrypt_sess_cookie' = TRUE/FALSE (boolean).  Whether to encrypt the cookie
| 'session_expiration'  = the number of SECONDS you want the session to last.
|  by default sessions last 7200 seconds (two hours).  Set to zero for no expiration.
| 'time_to_update'        = how many seconds between CI refreshing Session Information
|
*/
$config['sess_cookie_name']        = 'ci_session';
// $config['sess_expiration']        = 7200;
$config['sess_expiration']        = 0;
$config['sess_encrypt_cookie']    = FALSE;
$config['sess_use_database']    = TRUE;
$config['sess_table_name']        = 'ci_sessions';
$config['sess_match_ip']        = FALSE;
$config['sess_match_useragent']    = TRUE;
$config['sess_time_to_update']     = 300;

Hope it helps someone.


Messages In This Thread
session set userdata, large multi-dimensional arrays - by El Forum - 12-15-2010, 08:10 PM
session set userdata, large multi-dimensional arrays - by El Forum - 12-15-2010, 08:18 PM
session set userdata, large multi-dimensional arrays - by El Forum - 12-16-2010, 03:43 AM
session set userdata, large multi-dimensional arrays - by El Forum - 12-20-2010, 12:46 PM



Theme © iAndrew 2016 - Forum software by © MyBB