KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I have a controller, which maps to section of my site and all of the pages within it (methods) should only appear if the user is logged in. Otherwise they should be redirected back to a login screen. To get it working I've just done this: function index() { if ($this->session->userdata('logged_in')) { $this->load->view('main'); } else { redirect('/login'); } } function archive() { if ($this->session->userdata('logged_in')) { and so on... repeating that check in each method. What's the simplest way of doing this check once for multiple-or-all methods in the controller?
Tags (comma-separated)
Save Edits
Cancel