Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to post non-post data into session when user logs in
    text
    copied!<p>When my users log into the website their first name, last name and ID are missing from the session data because my session data is coded to take post data and submit into the session table in my database.</p> <p>Because user logs in with email and password in my session data only email appears and nothing else does.</p> <p>How can I make first name, last name and id appear in my session table in my db? I want to some how grab these details from the database when user is logging in and provide it in my $u_data array so it get's posted upload login success. </p> <p>Here is my code:</p> <pre><code>&lt;?php class Login_Model extends CI_Model { public function checkLogin() { $this-&gt;db-&gt;where('email', $this-&gt;input-&gt;post('email')); //compare db email to email entered in form $this-&gt;db-&gt;where('password', $this-&gt;hashed()); //compare db password to hashed user password $query = $this-&gt;db-&gt;get('users'); //get the above info from 'user' table if ($query-&gt;num_rows() == 1) { //if number of rows returned is 1 $u_data = array( //new variable with session data 'user_id' =&gt; $this-&gt;db-&gt;insert_id(), 'email' =&gt; $this-&gt;input-&gt;post('email'), 'first_name' =&gt; $this-&gt;input-&gt;post('first_name'), 'last_name' =&gt; $this-&gt;input-&gt;post('last_name'), 'logged_in' =&gt; TRUE ); $this-&gt;session-&gt;set_userdata($u_data); //send data from variable to db session return TRUE; } else { return FALSE; } } public function hashed() { //hashing method // sha1 and salt password $password = $this-&gt;encrypt-&gt;sha1($this-&gt;input-&gt;post('password')); //encrypt user password $salt = $this-&gt;config-&gt;item('encryption_key'); //grab static salt from config file $start_hash = sha1($salt . $password); $end_hash = sha1($password . $salt); $hashed = sha1($start_hash . $password . $end_hash); return $hashed; } } </code></pre> <p><img src="https://i.stack.imgur.com/CqVsg.png" alt="alt text"></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload