I'm trying to set session data for users when they log in 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 and is logged i do:
if($this->session->userdata('user_exists')){
//do somenthing for logged user
}
Now I'm wondering if this means that user is logged and exists in the database since he logged and I set him a session param, is this true? Or I'll get security problems?
NB: I'm using session database
Using Codeigniter, this URL is a new function in the controller used for registration. In this example, the register_email_exists () function returns true or false, after checking the entered form value against the database.
When the cursor leaves the username field (an event referred to in JavaScript as onblur, a username check is done in the background through an ajax call to the server without the user even clicking the submit button.
If a user with the provided username already exists in the database, a validation message with appropriate styling is displayed right away. Create a file named register.php and paste this code in it:
The user agent name definitions are located in a config file located at: app/Config/UserAgents.php. You may add items to the various user agent arrays if needed. When the User Agent class is initialized it will attempt to determine whether the user agent browsing your site is a web browser, a mobile device, or a robot.
//session encryption is mandatory
$sess_id = $this->session->userdata('user_id');
if(!empty($sess_id))
{
redirect(site_url().'/reports');
}else{
$this->session->set_userdata(array('msg'=>''));
//load the login page
$this->load->view('login/index');
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With