Welcome Guest, Not a member yet? Register   Sign In
Best practices: access session variable or save to class variable?
#1

[eluser]jprateragg[/eluser]
I'm new to CodeIgniter and have a question about best practices when dealing with frequently session data. In my session, I store the user id, user name, and some other things. I have several models/functions where I need to pass the user id. When I call the function, I've been calling:

Code:
$this->User->get_user_info($this->session->userdata('user_id'))

Would it be okay to save this data to a variable in MY_Controller instead so I can simply enter $this->user_id instead of typing out all the characters when using the session library? Is this better? Any security concerns? Thanks!
#2

[eluser]Aken[/eluser]
Nothing wrong with that. Makes sense to do that, to save yourself from being redundant.




Theme © iAndrew 2016 - Forum software by © MyBB