Welcome Guest, Not a member yet? Register   Sign In
The Easiest Authentication Library for CodeIgniter just got easier.
#80

[eluser]Jbeasley6651[/eluser]
I did a quick browse of the thread and didn't find anyone talking about the bug i found this morning so i'll post it. (sorry if it's been posted)

I was building an app to save the users information into a profile and I was trying to get the logged in users ID, no luck because you need to change the following.

in Auth.php on line 237 and line 144

From

Code:
'user_id' => $row['id'],

to

Code:
'id' => $row['id'],

the script is writing the column "user_id" to the session data and this is not a valid field in the database. You need to change it to "id"

Then, if you wanna make it easier on yourself to use the user id in multiple places open up the auth_helper and find this

Code:
function username()
{
    $CI =& get_instance();
    return $CI->session->userdata('username');
}

directly below it add this

Code:
function userid()
{
    $CI =& get_instance();
    return $CI->session->userdata('id');
}

Now, where ever you would like to use the user id you can simple use

Code:
<?php echo userid(); ?>

Thanks,

Joel Beasley


Messages In This Thread
The Easiest Authentication Library for CodeIgniter just got easier. - by El Forum - 05-30-2009, 08:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB