I have a login system. How can I implement a secure remember me system using cookies.
What value should I have to store in cookie username and password, but how I can secure it?
define A Salt foreach user in db then
on setting
$expire_time = time() + 2 * 7 * 24 * 3600; // 2 weeks exp time
setcookie(
"rememberMe",
crypt($username, $salt),
$expire_time,
'/'
);
on validating
$_COOKIE['rememberMe'] === crypt($username, $salt)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With