(08-13-2019, 08:04 AM)Wouter60 Wrote: If you have a controller for login, I'm sure you are using a session variable to "remember" if a user is logged in. Or a library that is active accross all controllers to check if a user is logged in.
Your FB like controller also needs to check this. If the user is not logged in, store the current url in a session variable, redirect to the login page, and after a succesful login, redirect to the url that was stored in the session.
I have this concept in MY_Controller.php (in application/core).
PHP Code:
protected function force_login()
{
if (! $this->ion_auth->logged_in() ) {
$this->session->set_userdata('redirect_after_login',current_url());
redirect('/login');
exit;
}
}
In every controller method that is only accessible for logged in users, I have this line:
If the user is already logged in, the application will simply continue with what it was doing. Otherwise, the user is routed to the login page, and after logging in, the application continues where it was.
I hope this will help you.
Thank ya this helps alot! My main goal is when a person logs in certain components work after logging in. Say for instance when a person logins into FB..they are able to post on their wall, DM, etc. It mostly about the members who are in the DB are connected and interact with one another and I feel that will be possible if the smaller controllers were connected to the Users controller.