Welcome Guest, Not a member yet? Register   Sign In
Help session grab user_id from database
#21

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

[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!!!
#23

[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
#24

[eluser]the_unforgiven[/eluser]
Anyone?
#25

[eluser]the_unforgiven[/eluser]
Please someone?
#26

[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
#27

[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.
#28

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

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

[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




Theme © iAndrew 2016 - Forum software by © MyBB