CodeIgniter Forums

Full Version: Inserting user ID into session userdata
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

I am trying to return the user ID into my userdata after a user logs in. I can store the username easily but I do not know how to get the id out of the db query without running it through a foreach.

The model selects all where $this->post->input(username) and $this->post->input(password). If affected row == 1, then it stores everything into an empty array called data. I can store the username by creating an array( username => $this->post->input(username)) and store this in the session.

The million dollar question is how to return the id from the sql in a form that I can store into the userdata of the session. if I try to insert it from the data array ($data['id'] or $data->idWink I get an error trying to access a non-object.

Thank you in advance for any advice.


El Forum

[eluser]Mike DeFelice[/eluser]
Can you post your model? It would be much easier to see what is going on.