Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

codeIgniter : losing session data after login

In codeigniter after login I am storing all the data into session and redirecting to forum controller. But I am losing all values in forum controller.

When I try after reducing some values from session it works perfectly.

Now my question is - why this is happening? Is there any upper limit of values to be store in session in codeIgniter?

Even I try to search I found like

redirect('forum', 'refresh');

But it is not working. And my project is half developed so I can't use "PHP Native Session class" of codeignter.

like image 541
Suresh Kamrushi Avatar asked Jan 02 '13 13:01

Suresh Kamrushi


2 Answers

By default CodeIgniter stores the session data in a cookie, which has an upper limit of 4KB in size. If you are trying to store more than 4KB of data in the session you will start running into issues.

The easiest solution is probably to store the session details in the DB. The CodeIgniter session documentation details the process for storing the session in the DB - it's a matter of setting up a table, and changing a couple of config parameters.

like image 65
ajshort Avatar answered Sep 28 '22 04:09

ajshort


The CI session stores everything in a cookie, with optional encryption. So apparently it is possible to reach that limit. That's if you store something like 2K bytes; if it is just login information, that shouldn't be a problem. If you do use something as big as that, well, I guess you shouldn't.

Anyway, I don't think this is the problem, as I had a similar problem (I don't remember the exact cause of this). The solution I found was to use the Native PHP Session class, and added one method to it: all_userdata or whatever it was called. With that, everything worked just like it would with the normal Session (no need to change anything).

like image 39
jadkik94 Avatar answered Sep 28 '22 04:09

jadkik94