Php $ _ COOKIE simple application instance _ PHP Tutorial

Source: Internet
Author: User
Php $ _ COOKIE simple application instance. COOKIE is before the webpage content is sent. The information sent first. That is to say. Before that, there cannot be any HTML code or echo, and even a space is not allowed .. COOKIE is before the webpage content is sent. The information sent first. That is to say. Before that, there cannot be any HTML code or echo, and even a space is not allowed ..

Cookie is before the webpage content is sent. The information sent first. That is to say. Before that, there cannot be any html code or echo, and even a space is not allowed ..

In the php Tutorial, you must use the setcookie function to register the cookie variable. the above code does not register the cookie variable. How can it be delivered. The correct syntax is as follows:

*/
$ Status = 0; // define the status
If (isset ($ _ cookie ['mytacky ']) & ($ _ cookie ['mytacky'] = "chocchip") $ status = 1; // if the variable has been set
If (! Isset ($ _ get ['cchk']) // if no variable is set
{
Setcookie ("mytstcky", "chocchip"); // send cookie information
Header ("location: $ php_self? Cchk = 1 "); // send the header
Exit; // end the php code
}
?>

Cookie check

Cookie check status:
Printf ('% s
; ', $ Status? "00ff00": "ff0000", $ status? "Passed! ":" Failed! "); // Output different content according to the condition
?>

Http://www.bkjia.com/PHPjc/631354.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/631354.htmlTechArticleCOOKIE is before webpage content is sent. The information sent first. That is to say. No HTML code or echo can be found before this, and even a space is not allowed .....

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.