PHP cookie operation implementation code (login) _ PHP Tutorial

Source: Internet
Author: User
PHP cookie operation implementation code (login ). The first file is login_frm.php. the code is copied in the login window. the code is as follows: htmlheadmetahttp-equivContent-Typecontenttexthtml; charsetutf8headbodyformmeth The first file login_frm.php. this is the logon window.
Code

The code is as follows:











The second file login. php is used to process the login

The code is as follows:


If ($ _ POST ['username'] = 'admin ')
{
Setcookie ('hahaha', 'gogogo ');
Header ("location: index. php ");
}
?>


The third file index. php looks at the effect again.

The code is as follows:


If ($ _ COOKIE ['hahaha'] = 'gogogogo ')
{
Echo $ _ COOKIE ['hahaha'];
Echo 'cookie you Set ';
}
Else
{
Echo 'You have not set cookies ';
}
?>


For more information, see PHP Cookies.

The authorization code is as follows: html head meta http-equiv = "Content-Type" content = "text/html; charset = utf8" // head body form meth...

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.