Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use Cookie in CGI

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the knowledge of "how to use Cookie in CGI". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

Using Cookie in CGI

A big disadvantage of http protocol is that it does not judge the identity of users, which brings great inconvenience to programmers, and the emergence of cookie function makes up for this deficiency.

Cookie is to write record data on the customer's hard disk through the customer's browser while visiting the script, and then retrieve the data information when the customer visits the script next time, so as to achieve the function of identity discrimination. Cookie is commonly used in identity verification.

Syntax of cookie

The http cookie is sent through the http header, which is earlier than the file transfer. The syntax of the header set-cookie is as follows:

Set-cookie:name=name;expires=date;path=path;domain=domain;secure

Name=name: the value of cookie needs to be set (name cannot use ";" and "," signs), separated by ";" when there are multiple name values, for example: name1=name1;name2=name2;name3=name3.

Expires=date: the validity period of cookie. Format: expires= "Wdy,DD-Mon-YYYY HH:MM:SS".

Path=path: sets the path supported by cookie. If path is a path, cookie takes effect on all files and subdirectories in this directory, for example: path= "/ cgi-bin/". If path is a file, cookie means to take effect on this file, for example: path= "/ cgi-bin/cookie.cgi".

Domain=domain: domain name that is valid for cookie, for example: domain= "www.runoob.com"

Secure: if this flag is given, it means that cookie can only be passed through the https server of the SSL protocol.

The reception of cookie is realized by setting the environment variable HTTP_COOKIE, which can be retrieved by CGI programs to obtain cookie information.

This is the end of the content of "how to use Cookie in CGI". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report