Welcome Guest, Not a member yet? Register   Sign In
Erkanauth class - checking if user is logged in
#1

[eluser]andriu[/eluser]
Hi

I'm still a bit new to CI an OOP.

At the moment to check if a user is logged in I check in every function
ex.:
Code:
function index()
    {
        if (!$this->erkanaauth->try_session_login())
        {
            redirect('admin/login');
          }else {
            
            $this->load->view('admin/page');
        }
    }

There must be a more efficient way to do this so I don't have to repeat the same code.

Thanks for any help.
#2

[eluser]Nerijus[/eluser]
You should create My_Controller.php file and do such a checking there I think.
#3

[eluser]bretticus[/eluser]
If you want about the simplest example possible, this one seems pretty easy to follow. BTW. I like simplicity when there's no need for something more complex. This example fits my bill.
#4

[eluser]andriu[/eluser]
Perfect

Exactly what I need, saves a lot of code.

Thanks




Theme © iAndrew 2016 - Forum software by © MyBB