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

#1
[eluser]kisin[/eluser]
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?

#2
[eluser]Grahack[/eluser]
I would be sure if I had your source code, but what often happens is that people code
Code:
if ($ok) {ok_processing();}
else {set_flashdata('key', 'message');load_the_view();}
Try
Code:
if ($ok) {ok_processing();}
else {set_flashdata('key', 'message');redirect('CI_uri_where_to_display_the_message');}

#3
[eluser]kisin[/eluser]
you are right - that was the problem.

#4
[eluser]worchyld[/eluser]
Thank for this grahack -- for some reason if you use:

Code:
// 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');
$this->load->view('mypage');

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

Code:
redirect('mypage');

Everything works fine!

#5
[eluser]Grahack[/eluser]
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]

#6
[eluser]Crimp[/eluser]
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.