flashdata and views inside views - 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 and views inside views (/showthread.php?tid=37352) |
flashdata and views inside views - El Forum - 01-06-2011 [eluser]xatrix[/eluser] Is loading a view inside another view considered a server request? I'm testing something and I've noticed that the flashdata is kept when I load the view without any included views. Everything fine here. But if that view were to include anything else, for example a header/footer view, the flashdata is lost. Why? flashdata and views inside views - El Forum - 01-06-2011 [eluser]Cristian Gilè[/eluser] Hi xatrix, flashdata are a type of session that will only be available for the next server request, and are then automatically cleared. For example, after a redirect. Including a view inside another view should not be a problem. Please, paste here a reduction code of your controller and views. Cristian Gilè flashdata and views inside views - El Forum - 01-06-2011 [eluser]xatrix[/eluser] Ninja edit: By whatever personal mistake or technological magic, things seem to be working now. Also a way to debug flashdata is to output it in your views as Code: <?php $v = $this->session->flashdata('referrer'); echo $v; $this->session->set_flashdata('referrer', $v); ?> flashdata and views inside views - El Forum - 01-07-2011 [eluser]InsiteFX[/eluser] If it makes more then one request you need to use keep_flashdata InsiteFX flashdata and views inside views - El Forum - 01-07-2011 [eluser]Cristian Gilè[/eluser] Your referrer session is not much reusable and you have had to modify ion_auth class while you can use a hook like this Cristian Gilè flashdata and views inside views - El Forum - 01-07-2011 [eluser]xatrix[/eluser] Hey thanks for the replies guys. As stated in my (unedited) second post, I was using keep_flashdata, but the problem was some weird browser caching bug. I cleared the cache and everything is ok now. And as to my modifying Ion Auth for redirecting the referrer, I agree it's not very reusable. It was just a placeholder. I think a better solution is to have a hidden field inside your form that stores the referrer page. |