I want to perform a simple check whether a user is logged in or not (based on the session) and redirect him somewhere in case he isn’t . This check needs to be done in all my controllers . Where do I put this check ? I know I can put it in all my controllers but that’s repeating code .
I know I can create a base controller with the check in it’s constructor , let all my other controllers inherit from it so they inherit the check .
Any other elegant solution for this ?
I want to perform a simple check whether a user is logged in or
Share
I would make a controller extending CI_Controller with the check in the constructor like you said, and then have your various other auth’d controllers extend that one.