CodeIgniter Forums

Full Version: Help session grab user_id from database
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5

El Forum

[eluser]weboap[/eluser]
whats in line 115 and 149 in your user.php ???

El Forum

[eluser]the_unforgiven[/eluser]
Found it, thought it was strange is wasn't doing this:

Code:
$this->session->set_userdata($data);
redirect('user/myaccount');

So in actual fact is was setting in the db has i checked that first then i got the white page, and thought something else was wrong so by adding those 2 lines in all has worked fine.

Much appreciated everyone's contributions, thanks a million guys the forum rules!!!

El Forum

[eluser]the_unforgiven[/eluser]
Come across another problem now:

When i logging with test/test has a customer which the id in the database is 15 which gets stored (or so i thought in the session) then log out the log out function unset's all user data for the session and does a session destroy too.
then i log in with me/me has the customer it shows me logged in but when i got to other details like account number and things i've set in the session it still shows has the test/test user is logged in.

Any idea's why this is have i missed something or not understanding... Sad

El Forum

[eluser]the_unforgiven[/eluser]
Anyone?

El Forum

[eluser]the_unforgiven[/eluser]
Please someone?

El Forum

[eluser]Ed Robindon[/eluser]
Hello,

I use the native PHP $_SESSION for session.

When a user successfully logs in I simply store the database row in a
session variable and all user info is available anywhere I need it.

Code:
$row = $query->row();
      //Validation code removed...
      $_SESSION['user']=$row;
      $_SESSION['loggedin'] = true;

Does this help any?

Ed

El Forum

[eluser]the_unforgiven[/eluser]
That's pretty much how it works now using what is stated in previous posts, but its leaving one user logged in instead of the new one i'm logging in has.

El Forum

[eluser]Ed Robindon[/eluser]
Correct me if I'm wrong but each user gets their own set of session variables...

El Forum

[eluser]the_unforgiven[/eluser]
yes thats my problem, its not doing has it should be

El Forum

[eluser]Samus[/eluser]
[quote author="the_unforgiven" date="1337876219"]That's pretty much how it works now using what is stated in previous posts, but its leaving one user logged in instead of the new one i'm logging in has.[/quote]
I think it's because you need to make your model method more 'dynamic'

As it is now

Code:
function getCustomer()
{
   $data = array();
   $options = array('id' => 14);
   $Q = $this->db->get_where('users',$options,1);
   if ($Q->num_rows() > 0){
        $data = $Q->row_array();
   }
     $Q->free_result();    
     return $data;
}

It's only searching for the user with id = 14.

Hope that helps. Smile
Pages: 1 2 3 4 5