Welcome Guest, Not a member yet? Register   Sign In
Off and on problem retrieving array from session
#1

[eluser]bigtimslim[/eluser]
I'm intermittently having trouble getting an array that I set as custom user data out of a session stored in a db.

Let me set the stage and try to explain what I'm doing real quick. I have a search feature that uses a few parameters to grabs data (title, link, data, desc) from 3 different site's rss feeds. The results are all combined and then stored in the session. The data is then paged with ajax. I have narrowed the problem down to one of the feeds. The initial search has always worked and stores the data (I check the db) and displays the first page. However, on some searches I get nothing from the array in the session, but I know the data is in the db.

When I make the function that gets the data store "test" for everything (title, url, etc), I have no problems at all. Through messing with it in this way, I have found the title in one search to be the problem and the description in another. This leads me to think something in this feeds data is causing the trouble. I strip_tags before inserting the data in the session/db. Should I do something else/more?

I would really appreciate any insight.
#2

[eluser]jalalski[/eluser]
are you serializing the array before popping it in the session?
#3

[eluser]bigtimslim[/eluser]
No I hadn't been. I just tried serializing the array before going in an unserializing it coming out, but I am having the prob still.

This, for example is how I am using it, should this be ok?

Code:
$this->session->set_userdata('search_results', serialize($results));

$results = unserialize($this->session->userdata('search_results'));


Edit: I must be so doing this wrong. Should I serialize every element of the array instead of the array itself? From the little I have just read, serializing "Returns a string containing a byte-stream representation of value that can be stored anywhere". When I look in my db the field data looks the same as before, by "byte-stream" I would think it looks not like this.
#4

[eluser]bigtimslim[/eluser]
well.. it appears as CI serializes this automatically.




Theme © iAndrew 2016 - Forum software by © MyBB