![]() |
Where is the best place to start my session? session_start() - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived General Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=21) +--- Thread: Where is the best place to start my session? session_start() (/showthread.php?tid=58533) |
Where is the best place to start my session? session_start() - El Forum - 06-20-2013 [eluser]Swammy[/eluser] Basically every page on my site can be accessed by a logged in user. So how do I globally make sure the session is starting on every page refresh? Code: session_start() Where is the best place to start my session? session_start() - El Forum - 06-21-2013 [eluser]anis2505[/eluser] Just auto-load the session library( for CI 2.X ) or the session driver( for CI 3.X ) or if you wish load the session library/driver on your controller constructor Where is the best place to start my session? session_start() - El Forum - 06-21-2013 [eluser]rose_anne[/eluser] You can auto load the session. The location of the file is can be found in "application/config/autoload.php" Where is the best place to start my session? session_start() - El Forum - 06-21-2013 [eluser]swgj19[/eluser] I would create a MY_Controller,php located in the core that extends the CI_Controller. Then I would create an Admin_Controller.php located in libraries that extends MY_Controller. For example, see this below: Code: <?php Then just extend whatever class to the Admin_Controller And to use the is_logged_in() function example: Code: function login_user() Where is the best place to start my session? session_start() - El Forum - 06-23-2013 [eluser]Swammy[/eluser] Okay thanks guys. So if I am autoloading sessions I should be fine on a global level? Great. Where is the best place to start my session? session_start() - El Forum - 06-24-2013 [eluser]Pert[/eluser] If you are using custom sessions, you should start it in index.php file. But yes, CodeIgniter sessions work very well, and allow you to do some cool stuff (automated flashdata!) |