The header header in PHP sets the difference between the cookie and the built-in Setcookie ____php

Source: Internet
Author: User

First of all, it is stated that the browsing cookie operation is implemented through the HTTP header (commonly known as the "HTTP Header"). All the cookie data transfers between the server and the client are done through the HTTP request header.

PHP Setcookie (function Implementation), is the HTTP header encapsulation, which seems to use the header and the use of Setcookie is the same.

Because header information belongs to HTTP protocol content, you must first send the head information to the server, then data download and other operations, so there is no content output before Setcookie and header (for example: echo/printf, etc.)

Header Set Cookie method:

1 Header ("Set-cookie:testcookie= Chinese"; path=/; domain=.sunphp.org; Expires= ". Gmstrftime ("%A,%d-%b-%y%h:%m:%s GMT", Time () + 9600));

Setcookie Setup mode:
Syntax: Setcookie (name,value,expire,path,domain,secure)
Cases:

1 Setcookie ("website", ' www.sunphp.org ', time () + 3600 * 24);

parameter description
name required. Specify the name of the cookie.
value is required. Specify the value of the cookie.
expire is optional. Specify the expiration date of the cookie.
path is optional. Specify the server path for the cookie.
domain is optional. Specify the domain name of the cookie.
secure is optional. Specify whether to transmit cookies through a secure HTTPS connection.

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.