My web application uses sessions to store information about the user once they\'ve logged in, and to maintain that information as they travel from page to page within the ap
My solution is like this. It's not 100% bulletproof but I think it will save you for the most of the cases.
When user logged in successfully create a string with this information:
$data = (SALT + ":" + hash(User Agent) + ":" + username
+ ":" + LoginTimestamp + ":"+ SALT)
Encrypt $data
, set type to HttpOnly and set cookie.
When user come back to your site, Make this steps:
:
character. If user signouts, remove this cookie. Create new cookie if user re-logins.