Organizational Research By

Surprising Reserch Topic

code igniter checking if user logged in for multiple pages


code igniter checking if user logged in for multiple pages  using -'codeigniter'

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?
    

asked Sep 15, 2015 by CorrineBarro
0 votes
5 views



Related Hot Questions

3 Answers

0 votes
NULL
answered Sep 15, 2015 by ErvinKnottvq
0 votes
NULL
answered Sep 15, 2015 by CraigLeworth
0 votes
NULL
answered Sep 15, 2015 by DMUPamelagzj

...