how to implement remember me using session in CI? |
version: 3.1.7
my config PHP Code: $config['sess_cookie_name'] = 'ci_session'; my login check function PHP Code: if($remember != 1) all my page have this script at they constructor PHP Code: public function __construct(){ i always using that script to implement remember me in codeigniter. But when i read the docs: https://www.codeigniter.com/user_guide/l...references i realize that i did wrong implementation. Because $this->session->sess_expiration is method to change global config session expiration time. This means, when 1 user not check remember me checkbox. any user that already logged in and checked remember me before, will be logout too in 2 hours later. CMIIW so i googling the solution again and found 2 way: 1. using cookie : https://stackoverflow.com/questions/3984...on-library Code: $cookie = array( since i dont want to use cookie, so i ignore this 2. using session exactly same as i did before. but when i read the docs, i know that this will not work then i read all session doc and i found tempdata : https://www.codeigniter.com/user_guide/l...l#tempdata so now my script login will be like this: PHP Code: $this->session->set_userdata('logged_in', 1); what i do: - set session logged_in = 1 when user and pass match - if remember me not checked, mark session logged_in as temp that will destory in 7200 sec later my question: is this the right way to implement remember me using session in CI ? |
Messages In This Thread |
how to implement remember me using session in CI? - by plonknimbuzz - 01-18-2018, 12:39 PM
RE: how to implement remember me using session in CI? - by Paradinight - 01-18-2018, 12:49 PM
RE: how to implement remember me using session in CI? - by PaulD - 01-18-2018, 12:58 PM
RE: how to implement remember me using session in CI? - by plonknimbuzz - 01-18-2018, 01:47 PM
RE: how to implement remember me using session in CI? - by InsiteFX - 01-18-2018, 10:46 PM
|