I'm developing an app in CodeIgniter and MySQL. The app include user profiles; am using Tank Auth to register and authenticate users.
I've setup a couple of users and now want to view each user's profile. I need to know:
1 - How to add custom session data into Tank Auth. I have an idea of how the code should look (http://codeigniter.com/user_guide/libraries/sessions.html), but am not sure where the code should go in the auth controller, which is rather extensive - https://github.com/ilkon/Tank-Auth/blob/master/application/controllers/auth.php.
2 - How to pass user data through to a view. I've setup a function to retrieve user data (see below) and want to pass it through to my profile view--I'm thinking that userdata (in the code) will represent the custom session data, which will include the user's id and username, one of which I'll need for the URL.
3 - URLs I want the URLs to look like this: http://example.com/users/3394 or http://example.com/users/fooy_foo. I know I need to do something with CI URI routing, but am not certain how to tie it in with the results I get from the query.
Here's the code from the User controller {
function index()
{
$id = $this->tank_auth->is_logged_in('id');
$this->db->where('id', $id);
$q = $this->db->get('user');
$data['userdata']=$q;
$this->load->view('user_view', $data);
}
}