0

I am a little confused about what I am doing.

I am using CodeIgniter. I want to fetch user profile information from the server. I set a user_id in session variable userId after successful login and write a query to fetch all user info in the Model:-

Type 1

$this->db->where('user_id',$this->session->userdata('userId'));
$res = $this->db->get('user_info');

Suppose 100 users are accessing their profile information at the same time.

How does the web server maintain each user request in the above scenario because models are obviously executing on the server and there are multiple sessions running at the same time.

Should I pass session variable 'userId' data in the URL, so my query will be

Type 2

$this->db->where('user_id',$this->uri->segment(3));
$res = $this->db->get('user_info');

Which is a better coding practice to get user profile information from server when 100s or 1000s of users are accessing the server at the same time, Type 1 or Type 2?

i alarmed alien
  • 9,412
  • 3
  • 27
  • 40
Gangesh Bhat
  • 11
  • 1
  • 8
  • See [passing session variables in PHP](http://stackoverflow.com/questions/871858/php-pass-variable-to-next-page) and [sessions on Wikipedia](https://en.wikipedia.org/wiki/Session_(computer_science)) – i alarmed alien Sep 20 '14 at 07:05

1 Answers1

0

I don't know Codeigniter but you need the session id only in special cases. The webserver and the php modul handles thee session automatically and multiple of it.

Micromega
  • 12,486
  • 7
  • 35
  • 72