Greetings,
I have an old project I'm trying to convert to CI v4 from CI v2, and I'm running into a little problem. I had an
Account controller which handled the site login. In the login function, I had something like this to load the site home (for which I have a controller and view) after login:
Unfortunately, using
redirect gives me a forInvalidRedirectRoute HTTP exception. I tried two other solutions:
- return redirect()->to('home'); Unfortunately, this seems to look for a home method in the Account controller class.
- echo view('home'); This loads the home.php view, but without a template and all the stuff it needs from its controller. The controller is made to load some news like so:
PHP Code:
$news_model = new News_model();
$data['news'] = $news_model->get_news();
$data['view'] = 'home.php';
echo view('template.php', $data);
Obviously, I could simply copy the above code in the Account controller, but that wouldn't be elegant at all, and mostly, at some point I would love the login to redirect to the page the user was on. Obviously, it wouldn't make much sense to have basically every possible controller and view inside the login handler.
Any help or suggestion would be much appreciated. Thank you!