![]() |
flashdata not working as expected without redirect() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: flashdata not working as expected without redirect() (/showthread.php?tid=34480) |
flashdata not working as expected without redirect() - El Forum - 09-30-2010 [eluser]shelton_dev_guy[/eluser] Hi all, I am developing an application that makes use of session->flashdata() for error/success messages on pages that use forms. As the admin of the site, I also use the Profiler to track what queries are being executed. When I enabled the profiler, I noticed that some of the queries were not showing up. For example, when a user wants to update their profile, a db->update() function is executed. After some digging, I realized that when I update the database, I set a flashdata variable and redirect to the same page, and the queries were not being saved to display in the profiler, but the flashdata never fails. When I modify my controller to load->view() instead of redirect(), the profiler shows the query, but now my flashdata is all messed up - it will never show until the next page load (sometimes 2 page loads.) All I did was comment out the redirects, as shown below. Controller: Code: if ($this->form_validation->run() !== false){ View: Code: <h1>Edit Your Profile</h1> Other information that may be useful: Config: Code: $config['sess_use_database'] = TRUE; Is there a better (native CI) solution for success/error messages other than using session->flashdata()? I'm not opposed to adding an extra library or a function to one of my custom helpers, but it seems like this can be fixed without a bunch of excess coding. If this post is not in the right area, can a mod please move it? Thanks, flashdata not working as expected without redirect() - El Forum - 10-01-2010 [eluser]danmontgomery[/eluser] http://ellislab.com/codeigniter/user-guide/libraries/sessions.html Quote:Flashdata flashdata not working as expected without redirect() - El Forum - 10-01-2010 [eluser]n0xie[/eluser] You could try my Message Library which solves this. flashdata not working as expected without redirect() - El Forum - 10-01-2010 [eluser]pickupman[/eluser] What happens when you try Code: if ($this->form_validation->run() !== false){ flashdata not working as expected without redirect() - El Forum - 10-01-2010 [eluser]shelton_dev_guy[/eluser] @noctrum So loading a view doesn't really make another http request? @pickupman If your solution does not work, I will try n0xie's library. Thanks for the replies! flashdata not working as expected without redirect() - El Forum - 10-01-2010 [eluser]danmontgomery[/eluser] [quote author="shelton_dev_guy" date="1285967180"]@noctrum So loading a view doesn't really make another http request?[/quote] No... redirect() makes another http request flashdata not working as expected without redirect() - El Forum - 10-01-2010 [eluser]shelton_dev_guy[/eluser] --Edited-- My question changed, so I will make another post. Thanks for the help -- I am going to use n0xie's message lib. |