session data, display profile URLs in CodeIgniter (w/Tank Auth) session data, display profile URLs in CodeIgniter (w/Tank Auth) codeigniter codeigniter

session data, display profile URLs in CodeIgniter (w/Tank Auth)


I guess Runar has answered #2 and #3 for you.For #1, open application/libraries/Tank_auth.php and the function name login. You will see these lines of code:

$this->ci->session->set_userdata(array(                                       'user_id'       => $user->id,                                       'username'      => $user->username,                                       'status'        => ($user->activated == 1) ? STATUS_ACTIVATED : STATUS_NOT_ACTIVATED,                                ));

set_userdata sets the session. You can add more variables to be set in the session here.


  1. I'm not familiar with Tank Auth, but I'd advice you to check out the official page for Tank Auth. Maybe you'll get a better understanding from reading about the library. Here's a tutorial that shows how to set up Tank Auth with CodeIgniter.

  2. By looking at your code, from the user controller, I see that you're passing data the correct way. You're passing it into the view as an array. In your view the array element will be available as a variable. So to use the data in the view you simply use the variable $userdata. If you'd like to add more data to include in the view, you simply add another element to the $data array!

  3. If you create a controller named users you will be able to reach it at www.example.com/users. You can then edit your index function to include a parameter $uid which will generate your desired url: www.example.com/users/3394.

Example on #3:

Lets say you have created the users controller. This would then be your index() function:

function index($userid) {  // You should probably have a model here that retrieves information  // about the user based on the userid  $data['user'] = $this->User_model->getUserInformation($userid);  $this->load->view('users', $data);}

That's one way you could set up your index function. The $userid variable is defined by the url www.example.com/users/1234. That's the way urls work in codeigniter. You can read more about it here.