SOLVED -- simple solution to session expiration |
[eluser]nuwanda[/eluser]
On a couple of threads... http://ellislab.com/forums/viewthread/152877/ http://ellislab.com/forums/viewthread/109645/ ...the discussion was about creating a true session expiration-on-close-browser and a quick way to check logged in status. I'm very new to CI, but I've come up with this. I've tested it in all modern browsers and it works perfectly. Hope it's of help to someone. Thanks to those who replied on those other threads. The code uses a remember_me cookie set on the basis of the remember_me checkbox in the login form. The login_helper checks the status of the remember_me cookie and the CI session cookie to work out if the user is logged in currently or is returning to the site and needs to be logged in. Simply setting the remember_me cookie to true is not enough. CI needs to have dropped a session cookie and the app needs to set it to logged_in=true. Logging out sets the remember_me cookie to zero and this deletes it when the browser closes. First there's login validation in my user controller: Code: function validate() Then there's a tiny helper that is used to check login status. This is autoloaded and can be used anywhere to include discrete sections of code, html, etc. Code: function logged_in()
[eluser]nuwanda[/eluser]
Ok, a glitch. If you open multiple tabs in Firefox it will ask you if you want to save them before quitting--that's a feature that reopens those same tabs at your *next* startup. In that case, the cookie set to 'current' is still present when you restart. This must be a FF glitch as all the documentation says the cookie should be deleted at browser close. Any ideas? |
Welcome Guest, Not a member yet? Register Sign In |