Welcome Guest, Not a member yet? Register   Sign In
How to verify if a user is logged in?
#2

(04-20-2015, 12:51 PM)lexxtoronto Wrote: Im using a session database. I set some custom data in the session:


Code:
           $sessiondata=array('username'=>$username, 'loginuser'=>TRUE);
                   $this->session->set_userdata($sessiondata);
                   
                   $sessionId_local = $this->session->userdata('session_id');
                   
                   $this->db->where('session_id',  $sessionId_local);  
                   $this->db->update('ci_sessions',$sessiondata);

So I set username and loginuser, then enter these values in ci_sessions table matching the session_id so that it is for the same user.

So login kinda works and the user is redirected to admin.php. What if I go to admin.php directly how do I verify if the user is logged in and is allowed to access admin.php?

I want to match data against ci_sessions table.




i use after login this code to verify if user loged or not

Code:
if(($this->session->userdata('user_name')==""))
  {
     $this->welcome();   }
        else
        {..........................
Reply


Messages In This Thread
RE: How to verify if a user is logged in? - by paju89 - 04-20-2015, 02:27 PM



Theme © iAndrew 2016 - Forum software by © MyBB