Welcome Guest, Not a member yet? Register   Sign In
Losing userdata between requests
#1

[eluser]andrecastelo[/eluser]
Hey guys.

I have a basic problem. I'm building a site where the user goes through a process to configure and set up an order, including an image selection phase, where he had to pick 1+ images. In the last step, I commit that order to the database, but during it, the order is stored in the session userdata. It was working perfectly up until a certain point - when I increased the minimum limit of the images selected to 80.

In each phase I check to see if the order is there, if it has all the elements needed for the step. If it doesn't, it redirects the user to the first step. After I added the limit, I keep getting redirected after adding the images (which is a simple array of strings, the image ids).

What could be the culprit in this case? (removing the image allows me to go through, but the order will have between 80 and 200 images).
#2

[eluser]noideawhattotypehere[/eluser]
apache? nginx? perhaps its best idea to add them to user session via ajax when selecting one by one. probably cookie size limit but thats just my wild guess
#3

[eluser]CroNiX[/eluser]
Are you using cookies or the database to store session data? I'm guessing cookies since it was working before with less data and only started breaking once you increased how much session data you are storing.

Cookies can only hold about 4k of data, and that's after it's encrypted which obviously increases the size of the data being stored.
#4

[eluser]andrecastelo[/eluser]
Yeah, I'm using apache and cookies. Is there a simplified way of using databased stored session data? Or if I can check the size of the cookie?
#5

[eluser]CroNiX[/eluser]
Yes, you just need to change the session type in the config, and then create the appropriate database table which is listed towards the end of the Session class in the User Guide.

Code:
$config['sess_use_database'] = TRUE;
$config['sess_table_name']   = 'session_table_name';

That's all you should need to do assuming you have already been using CIs session class and its methods. Sessions will still send a cookie, but it will only contain the encrypted session ID which is fairly small and no actual session data, so it won't be a problem. This is also more secure since the session data can't be manipulated or accessed in any way since it's never sent to the client browser with the rest of the cookie.
#6

[eluser]andrecastelo[/eluser]
Thanks Cronix. Would I need to create a specific table for the data types that I'm trying to use or would that be automatic?
#7

[eluser]noideawhattotypehere[/eluser]
Code:
CREATE TABLE IF NOT EXISTS  `ci_sessions` (
session_id varchar(40) DEFAULT '0' NOT NULL,
ip_address varchar(45) DEFAULT '0' NOT NULL,
user_agent varchar(120) NOT NULL,
last_activity int(10) unsigned DEFAULT 0 NOT NULL,
user_data text NOT NULL,
PRIMARY KEY (session_id),
KEY `last_activity_idx` (`last_activity`)
);

http://ellislab.com/codeigniter/user-gui...sions.html

for real now, read userguide, it wont bite you
#8

[eluser]aling01[/eluser]
Would this be the same as my scenario where we have a bunch of pages: If I were to edit a page/post that has an image already in there (suppose to anyways), every time I go in and edit that page/page I would have to reselect the image. If I don't it disappears when viewing the site.
#9

[eluser]CroNiX[/eluser]
[quote author="aling01" date="1405542342"]Would this be the same as my scenario where we have a bunch of pages: If I were to edit a page/post that has an image already in there (suppose to anyways), every time I go in and edit that page/page I would have to reselect the image. If I don't it disappears when viewing the site. [/quote]
This doesn't sound like a session issue.
#10

[eluser]aling01[/eluser]
Would you be able to point me in a direction where I can get more info on my issue? I dont know much about EE.




Theme © iAndrew 2016 - Forum software by © MyBB