How to ensure that cookies are not forged when using cookies to save logged-in user information
You master. Ask you a question, I would like to use a cookie to save the user login, the purpose is to use the HTML page (display user name and automatically fill in the text box), and to be able to login for a period of time.
Excuse me, please. How can I guarantee that a cookie will not be forged?
Next open the page to detect if there is a remember password login
if (Isset ($_cookie[' user_id ') &&isset ($_cookie[' rand '))
{
$user _id=$_cookie[' user_id '];
$spuerpass = "20120412001@#";
$rand =MD5 (MD5 ($user _id. $spuerpass));
if ($_cookie[' rand ']== $rand)
{
$_session[' user_id ']= $user _id;
}
}
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.