Re:How is "remember me" functionality implemented in famous ...
by yassersouri on Sunday November 07, 2010 @08:11AM
(#1879261)
thank you. But this totally lacks security. What if someone steals the cookie?
Re:How is "remember me" functionality implemented in famous ...
by bl4k on Sunday November 07, 2010 @08:35AM
(#1879289)
you are screwed either way. that is what Firesheep does
the solution is to use SSL and set the secure flag on the cookie
Re:How is "remember me" functionality implemented in famous ...
by yassersouri on Sunday November 07, 2010 @01:52PM
(#1880018)
I mean what if some one steals your cookie from your machine and copies it to his machine, this way he can login as you. I feel there is a way to prevent this, but I have no idea
The other way to do it is to use the existing session support. If the 'remember me' box is checked, you change the session so that instead of it expiring at the end of the browser session, it expires way into the future.
ie. your login script probably looks like this:
you need to change it to: the key function is session_set_cookie_params() which will let you alter the cookie that the session store uses prior to seeting it:http://php.net/session_set_cookie_params
note: that you need to call it before you call session_start(). $lifetime just calculates the number of seconds in 10 years, and the time set is time() (ie. now) plus the number of seconds in 10 years.
note: filter_func is a function that you write that will filter input variables, and $db is whatever your db class or access method is.
note: you also need to filter $_SESSION. most devs have a class that they wrap $_SESSION in rather than using it directly.