PHP Session Remember Me Functionality -


i making website uses php sessions "logging in" , having account. default, user logged out when close browser, due cookie expiring. want implement "remember me" or "keep me logged in" functionality website. there 2 possible solutions have considered.

  1. extend lifetime of session cookie not expire when user closes browser
  2. add second cookie randomly generated sequence of characters identifies user. key associated user's id in database. when user visited site, key/id pair retrieved database, , if match, user logged in. cookie http only.

what pros , cons each type of method , either pose severe security risk? also, there better method of approaching problem? thanks.

the lifetime of session cookie depends on settings in php.ini (session.timeout , session.gc_maxlifetime). pro is, whole session remembered (not login)

see https://www.sitepoint.com/community/t/php-session-does-not-expire-on-closing-browser/6831/2

remember me should bei done cookie identifies user because can handle lifetime better , doesn't hold whole session information.

depends on want remember.


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -