Welcome Guest, Not a member yet? Register   Sign In
Sessions expiring after browser closes
#5

[eluser]AgentPhoenix[/eluser]
I built my own authentication library for my application and am using cookies to do an auto-login feature. It's actually pretty easy.

When the login method fires, there's an option to set a cookie so the site remembers the user. If that option is set, I set a cookie with their email address and password (the items required for them to login). Now, they've got a cookie set on their computer that can be used later on.

Say they close their browser and come back a few hours later. When they get to the site, the constructor has a call to a method in the library that checks to see if they're logged in. If they aren't logged in, it checks for the cookie to see if it should try an autologin. If there is a cookie, it pulls the email address and password out of the cookie and feeds it to the login method (which in turn sets session variables, etc.). If the cookie doesn't exist, it kicks them over to the login page.

That's pretty much it.


Messages In This Thread
Sessions expiring after browser closes - by El Forum - 11-09-2009, 06:13 AM
Sessions expiring after browser closes - by El Forum - 11-09-2009, 06:30 AM
Sessions expiring after browser closes - by El Forum - 11-09-2009, 07:09 AM
Sessions expiring after browser closes - by El Forum - 11-09-2009, 10:52 AM
Sessions expiring after browser closes - by El Forum - 11-09-2009, 12:05 PM
Sessions expiring after browser closes - by El Forum - 11-09-2009, 12:17 PM
Sessions expiring after browser closes - by El Forum - 11-09-2009, 01:00 PM
Sessions expiring after browser closes - by El Forum - 11-09-2009, 01:24 PM
Sessions expiring after browser closes - by El Forum - 11-09-2009, 02:21 PM
Sessions expiring after browser closes - by El Forum - 11-10-2009, 05:43 AM



Theme © iAndrew 2016 - Forum software by © MyBB