Best practices: access session variable or save to class variable? - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Best practices: access session variable or save to class variable? (/showthread.php?tid=55656) |
Best practices: access session variable or save to class variable? - El Forum - 11-05-2012 [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! Best practices: access session variable or save to class variable? - El Forum - 11-06-2012 [eluser]Aken[/eluser] Nothing wrong with that. Makes sense to do that, to save yourself from being redundant. |