Page 1 of 1

CodeIgniter - call another controller from a controller

Posted: Mon Aug 29, 2011 11:16 am
by tigor
I know this is not the best practice, but feels like i really need to reference another controller from some other controller.
Here is the deal -
1. I have service controller, which wraps some functionality of a web application.
2. The web application controller on every request verifies session.
3. In order to create a session in a service, I extend the Login controller, do the login and then i need to call for a controller of a web application.
I could simply duplicate the code, but this seems even worse then accessing controller.

If i simply instance the class, naturally the class has no controller context, thus, somehow i need to get reference to that controller from the CodeIgniter.
Any suggestions ?

Thank you in advance.

Re: CodeIgniter - call another controller from a controller

Posted: Mon Sep 12, 2011 2:16 am
by greip
When the login controller finish doing its stuff, do a 302 redirect to the page you want the user to see next.

Re: CodeIgniter - call another controller from a controller

Posted: Sat Oct 29, 2011 1:38 am
by uday8486
You actually can't call a controller within a controller, You can use helper to accomplish your task.

Or Can view this link to get a better idea
http://codeigniter.com/forums/viewthread/55212/