Welcome Guest, Not a member yet? Register   Sign In
Annoying flashdata problem
#1

[eluser]juan1904[/eluser]
Hi,

I've got a really annoying problem with flashdata. I've got a formula and when that is filled i've got a checker controller which checks if the information is correct or not. If it's correct you get to look at the data you filled the formula with and then choose either Confirm or Edit. If you choose Edit you get back to the formula which is filled with the information you typed last time.

When I click Edit on the confirmation page I do get the formulas filled sometimes but sometimes the flashdata doesn't exist even if it should. I've tried to do print_r($array) to see if the array I put into the flashdata really exist in the confirmation page, and it does (always!) and then I've tried to print_r($flashdata) on the formula-page to see if the flashdata does exist after the new HTTP-request, and it doesn't sometimes, but sometimes it does.

I've tried to find the problem for about 10 hours now but I don't know... Is there anyone out there who's had the same sort of problem with flashdata?

I rather not copy code to you guys because my controllers are hugh (about 600 rows).

Greetings
Johan from Sweden
#2

[eluser]IsaacS[/eluser]
It might just be something to do with cookies not being stored correctly? Are you using a redirect after calling set_flashdata?

You might want to try using database sessions if that is the case, or using a table to store temporary data separately - then you don't rely on cookies, or the client machine at all!

Table structure could be:

id | userid | varname | value

Then on the page load where you fetch the flashdata, you just look in that table for a row with the right varname and the userid for the logged-in user, and grab that value. Once you've got the value, you can delete that row.

There's probably a much better reason for this not working, but I'm a bit of a CI newbie myself, but this table method is what I've used before in plain PHP.

Good luck!

Isaac
#3

[eluser]juan1904[/eluser]
IsaacS,

Thanks for the reply. I am using a redirect after set_flashdata yes. And sometimes the flashdata is correctly there when doing a new HTTP-request and sometimes it's not. The cookies being stored correctly? Hm, I checked my Mozilla Firefox settings and it's default on cookies (allow cookies).

I really would like to get a simple solution to this. If there's anyone else out there that knows alot about flashdata in CI and might know what sort of problem this is, please help! Smile
#4

[eluser]juan1904[/eluser]
Alright I'm pretty sure that my flashdata-array contains too much information somehow. I've got alot of other arrays in the flashdata-array and so on. But it did work perfectly fine on my website before when I didn't use CI. Is there a limit in CI-flashdata/sessions? I tried to do it with a $this->session->set_userdata(); aswell but it's the same problem there.

IsaacS: Do you know if that database-solution works even if my flashdata contains too much information? Or do I need to make another solution with PHP sessions and not CI?
#5

[eluser]juan1904[/eluser]
Problem is now solved!
Google is my friend and it helped me alot today. After way too many hours I found there's another Session-class that I found on Codeigniter's wiki, this one doesn't use cookies, it uses the native PHP-session function which can store more data than cookies, that helped me alot and I no longer got a problem!

Thanks to IsaacS for replying though, appreciate it! Smile
#6

[eluser]IsaacS[/eluser]
Glad it's sorted. The reason I asked about redirect is that sometimes browsers reject cookies on a page which returns a 301 Redirected error - thereby losing your data. CI's built-in sessions can run off the database, it's somewhere in application/config/config.php I believe.

Isaac




Theme © iAndrew 2016 - Forum software by © MyBB