Codeigniter – check if user is logged and exists (it's a real user)

I’m setting a session data for users when they log to my website.

So if the user exists in db i set a session data like : $this->session->set_userdata('user_exists','1');

Now every time i want to check if user exists & is logged i do:

Now i’m wondering if this means that user is logged & exists in db since he logged & i setted him a session param, is this true? Or i’ll obtain security problems?

NB: i’m using session database

thanks

//session encryption is mandatory