• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
flashdata problem

i have a strange problem -
im using db session and when im using the set_flashdata method i see the data only after i refresh my page twice.

for example, i use flashdata in my login form when the login falied but the flashdata is only seen on the screen in the second time the login falied.

any ideas what the problem can be or from where to start looking?

I would be sure if I had your source code, but what often happens is that people code
if ($ok) {ok_processing();}
else {set_flashdata('key', 'message');load_the_view();}
if ($ok) {ok_processing();}
else {set_flashdata('key', 'message');redirect('CI_uri_where_to_display_the_message');}

you are right - that was the problem.

Thank for this grahack -- for some reason if you use:

// Uses the OBSession library as found in http://codeigniter.com/wiki/OB_Session/ and http://bleakview.orgfree.com/obsession/
$this->session->set_flashdata('msg', 'Save succeeded');

You have to reload the page, sometimes twice, but if you redirect the page, ala:


Everything works fine!

The reason is flashdata "will persist only for the next request", maybe we could add "and not before it".

[url="http://codeigniter.com/wiki/Native_session/"]see here[/url]

The OB_Session implementation of flashdata has been included in the CI core by Derek Allard. If you download CI from SVN, you can avoid using another Session library.

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.