Need to post twice to display flashdata message. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Need to post twice to display flashdata message. (/showthread.php?tid=18301) |
Need to post twice to display flashdata message. - El Forum - 05-01-2009 [eluser]djalilk[/eluser] Hi everybody, I am new to codeIgniter and trying to create a login system, and didn't find any solution to my problem : when I try to login, if the username or the password is wrong the flashdata message is displayed only if I submit my form twice. here is the controller function: Code: function verify(){ the model : Code: function verifyAdmin($user, $password){ And the view : Code: <div id="pleft"> Please help me Thank you. Need to post twice to display flashdata message. - El Forum - 05-01-2009 [eluser]Steven Richards[/eluser] Flashdata is only available on the next request, not for the current one. You can use userdata instead or use a redirect. Need to post twice to display flashdata message. - El Forum - 05-02-2009 [eluser]djalilk[/eluser] Thanx a lot it works with userdata I don't understand is why flashdata is used in the book "professional codeigniter" ? (wich is excelent) Need to post twice to display flashdata message. - El Forum - 05-02-2009 [eluser]Steven Richards[/eluser] Flashdata is very useful for its intended purpose: storing a temporary piece of data to be used in the very next request. It takes care of disposing of that data for you automatically so you don't forget (and so it doesn't eat up your limited amount of cookie space if it doesn't need to be hanging around for the rest of the session). Need to post twice to display flashdata message. - El Forum - 05-02-2009 [eluser]djalilk[/eluser] Sorry but I don't undestand, I use flashdata in the next request but I need to post my form twice to get the message Need to post twice to display flashdata message. - El Forum - 05-02-2009 [eluser]TheFuzzy0ne[/eluser] Flashdata is set, and then retrieved on the request after. Generally, you'll see flashdata being set just before a redirect is made, and then the data is pulled from the flashdata variable after. Here's a quick example (untested): ./system/application/controllers/test.php Code: class Test extends Controller I'd also like to point out that using $_SESSION is not a good idea when using CodeIgniter's session class. You'll probably encounter a lot of problems. Hopefully this helps. |