Validating user sessions in PHP/CI - 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: Validating user sessions in PHP/CI (/showthread.php?tid=10913) |
Validating user sessions in PHP/CI - El Forum - 08-18-2008 [eluser]codeboy[/eluser] Hi All, I am sorry if this is a basic question, but I am new to PHP/CI. I am developing a web application using CI and I will need to do a couple of basic things: 1. I will need to logout an inactive user after 20 minutes. 2. I also want a clean way of validating a user session every time they navigate to a URL after they have logged in. The obvious thing that I can think of is to call a validate_user_session method from every function in the controller, but I dont know if that is a clean way of doing it. Any pointers are appreciated. Thanks, CB Validating user sessions in PHP/CI - El Forum - 08-18-2008 [eluser]Dan Bowling[/eluser] I'm really new to CI, so take my advice with that context. What I've done on a current project that needed some security, but not a lot, is modified the Session variables setting: Code: $config['sess_expiration'] = 7200; That is the timout of the session in seconds (the default is two hours). In my controllers (all that require authentication), I've put a session check in the constructor: Code: class Schools extends Controller { Validating user sessions in PHP/CI - El Forum - 08-19-2008 [eluser]codeboy[/eluser] This looks good and is what I wanted. Thanks! Validating user sessions in PHP/CI - El Forum - 08-21-2008 [eluser]RaZoR LeGaCy[/eluser] Couldn't do this too? Code: if (!$this->session->userdata('logged_in')) |