Redirect & flashdata - 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: Redirect & flashdata (/showthread.php?tid=15320) |
Redirect & flashdata - El Forum - 01-31-2009 [eluser]The Wizard[/eluser] Hello friends, when you've setup some flashdata and do a redirect() the data gets lost. that is nasty and shouldnt happen take care Redirect & flashdata - El Forum - 02-01-2009 [eluser]t'mo[/eluser] I just worked on a site that uses this just the other day, and it seems to be working for me. Are you using the same name/key for the flashdata in both places? E.g., does the controller code: Code: $this->session->set_flashdata('foo', 'your request was saved...'); match the view code that pulls out the value? Code: <?=$this->session->flashdata('foo');?> They have to have the same name. Finally, are you autoloading the session library, so it's available everywhere? If you're "manually" loading it, you might have forgotten it somewhere. Redirect & flashdata - El Forum - 02-01-2009 [eluser]The Wizard[/eluser] have to double check that, will post when i do thanks. Redirect & flashdata - El Forum - 09-07-2009 [eluser]yayot[/eluser] Im trying to do something similar, but I want to check, depending if the flashdata has been set, to redirect to a default page... or another page. In other words, how do I check if the flashdata has been set? Thanks Redirect & flashdata - El Forum - 09-28-2010 [eluser]jloosli[/eluser] I've been playing around with this and came up with a workaround that works fairly well for me. What I've done is simulate a redirect through an automatic form submission: First, create a view called "redirect_with_message.php" (codeigniter removes the script tags, so put them in when you create your file): Code: //script tag goes here Code: <?php Now, if I want to send a message along with the redirect, I use Code: <?php Code: <?php Redirect & flashdata - El Forum - 12-28-2010 [eluser]Dushan[/eluser] I load a model in one controller, then I save it in flashdata, then I redirect to another controller and I can't access that model there. If I try to access a method from that model I get the following error: Fatal error: Call to a member function get_username() on a non-object in C:\wamp\www\CI172\dev\system\application\controllers\profile.php on line 28 How can I keep using the same model even if I redirect to another controller? Thanks! Dushan Redirect & flashdata - El Forum - 12-29-2010 [eluser]InsiteFX[/eluser] Create a MY_Controller and extend your other controllers from it. or You can Autoload the Model. This is in the CodeIgniter User Guide. InsiteFX Redirect & flashdata - El Forum - 12-29-2010 [eluser]Dushan[/eluser] What I am trying to do is reduce the work of loading the same model as I redirect() from one controller to another. I would like the same instance/state of my model exist in my second controller. The simplest approach I thought of is by placing it in the flashdata, but that didn't seem to work and produced the error I mentioned above. Are my only options to reload the model either through autoload or through MY_Controller class? |