CodeIgniter Forums
"remember me" sessions. (And "not remember me"). Can the user have a choice? - 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: "remember me" sessions. (And "not remember me"). Can the user have a choice? (/showthread.php?tid=30875)



"remember me" sessions. (And "not remember me"). Can the user have a choice? - El Forum - 05-28-2010

[eluser]tomdelonge[/eluser]
Alright, so the session class is great. But I can't figure out how to do something. The "remember me" checkbox on login should have the cookie set to some longer period of time (hours or days or weeks, whatever). And if it's not checked, then the cookie expiration needs to be set to 0 (isn't that right?).

At any rate, in the config.php file, you can set your session configuration. How can I possibly have a choice when the user logs in? Or is this way too complicated to even accomplish?

Ideas?


"remember me" sessions. (And "not remember me"). Can the user have a choice? - El Forum - 05-28-2010

[eluser]WanWizard[/eluser]
You need to extend the session library to have support for sess_expiration 0 (valid till end of browser session), by default CI doesn't support this.

This allows you to check in your MY_Session constructor for the existence of a 'remember_me' cookie, and modify the value of sess_expiration before the session library creates, loads or updates the session. Your login controller should create this 'remember_me' cookie.


"remember me" sessions. (And "not remember me"). Can the user have a choice? - El Forum - 05-29-2010

[eluser]Stolz[/eluser]
PK Session

A MY_Session that includes a method to create a session cookie that expires when browse closes.

http://codeigniter.com/wiki/PK_Session/