Explanation of the Set-cookie option in the HTTP header

Source: Internet
Author: User
Tags http cookie
We are in some of the message book, BBS discussion area post often this phenomenon: when entering the Post interface in the request to fill in the user name and password where it has been automatically filled with your information. What the hell is going on here? This is because of the introduction of cookie technology in the program. It turns out that the first time you log in, the program has installed a cookie packet on your computer, and the computer automatically retrieves your cookie and takes out the information for the program to call when you log in later, so the phenomenon described above appears.

A

Cookie is simply a message packet that a CGI program requires a browser to hold, and this packet can be retracted by the CGI program at any time. Whenever a CGI program requires a cookie to be created, the cookie can be transferred from the server to the subdirectory that the browser belongs to (typically the directory stored in the C:\WINDOWS\Temporary Internet files, which is called a cookie installation. The installation and readout of the
    cookie is usually done by a CGI module, and I will publish the original code of this module to everyone, and with this cookie module we can say that it is easy to apply cookie technology when writing a program. The syntax of the
Cookie:  
The HTTP cookie is sent over the HTTP header, and he is earlier than the file, with the syntax of the header Set-cookie as follows:  
Set-cookie:name=name; Expires=date;path=path;domain=domain;secure Name=name: You need to set the value of the cookie (name cannot use ";" and ","), with multiple name values separated by ";" For example: name1= name1; Name2=name2;name3=name3.
Expires=date:cookie Expiration date, format: expires= "wdy,dd-mon-yyyy HH:MM:SS"  
Path=path: Sets the path supported by the cookie if path is a path , the cookie takes effect on all files and subdirectories in this directory, for example: Path= "/cgi-bin/", if path is a file, the cookie refers to the file, for example: Path= "/cgi-bin/cookie.cgi".
Domain=domain: The domain name that is valid for the cookie, for example: domain= "Gzdzw.51.net"
Secure: If this flag is given, the cookie can only be passed through the HTTPS server of the SSL protocol. The receipt of the
cookie is implemented by setting the environment variable Http_cookie, which can be retrieved by the CGI program for cookie information.

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.