One week the session open to expire is secure - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12) +--- Thread: One week the session open to expire is secure (/showthread.php?tid=64084) |
One week the session open to expire is secure - edica - 01-13-2016 Hello, On a website where the user can log in. One week the session open to expire is secure? ($config['sess_expiration'] = 604800) Thanks. RE: One week the session open to expire is secure - Narf - 01-13-2016 No, it should be a few hours at most; implement a "remember me" cookie for longer times. RE: One week the session open to expire is secure - edica - 01-13-2016 When user enter the site should verify if cookie exists. See code below. There is another way better? library class: class Autologin { protected $CI; public function __construct() { $this->CI =& get_instance(); if (!$this->CI->session->userdata('logged_in')) { $this->auto_login(); } <==== This is cool? } public function auto_login() { $this->CI->load->helper('cookie'); $this->CI->load->library('session'); $user_name = get_cookie('user_name'); $user_email = get_cookie('user_email'); if (!empty($user_email) && !empty($user_name)) { $user_data = array( 'nome' => $user_name, 'email' => $user_email, ); $this->CI->session->set_userdata('logged_in',$user_data); $arr = $this->CI->session->all_userdata(); } } } RE: One week the session open to expire is secure - meow - 01-13-2016 I cant remember where I learned it, but I use: PHP Code: <?php then in the construct PHP Code: $this->logged_in = ($this->session->userdata('signed_in')) ? TRUE : FALSE; So, as soon as user is logged in, I set a sessiondatapiece signed_in = 1 RE: One week the session open to expire is secure - edica - 01-14-2016 But I'd like to verify if exist cookie when open the site. On any page of the site. Thanks. |