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

(This post was last modified: 04-20-2015, 01:29 PM by lexxtoronto.)

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.
Do the one thing you think you cannot do. Fail at it. Try again. Do better the second time. The only people who never tumble are those who never mount the high wire.
Reply


Messages In This Thread
How to verify if a user is logged in? - by lexxtoronto - 04-20-2015, 12:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB