CodeIgniter Forums
redirect('dashboard', $data) - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forum-20.html)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forum-23.html)
+--- Thread: redirect('dashboard', $data) (/thread-11255.html)



redirect('dashboard', $data) - El Forum - 09-01-2008

[eluser]Boyz26[/eluser]
Hi everyone,

Is it possible for me to pass variables to redirects (eg. redirect('index',$data), like we usually pass into $this->load->view('index', $data)?

I tried searching the forum but couldn't find a solution, so I would be grateful if anyone could answer this question.


redirect('dashboard', $data) - El Forum - 09-01-2008

[eluser]beemr[/eluser]
redirect just sends a redirect header, so the only way to pass data is through the URL. You could redirect to example.com/dashboard/index/user/155.

If dashboard is a method in the same controller, you could just call that method rather than redirecting to it.

Finally, if you don't mind extending the core there are libraries such as Modular Extensions and Matchbox that should provide what you're looking for. I know of a core hack called Controller Forwarding or maybe just Forward that will let you forward your data to the default method of another controller.


redirect('dashboard', $data) - El Forum - 09-01-2008

[eluser]Colin Williams[/eluser]
If the method is at another controller, you just need to pass it a URI that the other controller method knows how to parse, like beemr said. "Controller Forwarding" seems a bit odd because the destination controller method should already be getting its information from the URI, so requesting the correct URI ought to work just fine. If you need to share data between the current request and the redirect, use session flashdata