Get the App
SLTechnology News&Howtos  ›  Development  › 

How to set up Cookie

Shulou Source: shulou.com Published: 2022-06-01 01:33:21 10月27日 Update

This article mainly explains "how to set cookies," interested friends may wish to have a look. The method introduced in this paper is simple, fast and practical. Let's take you to learn "How to set cookies"!

Cookie settings

Cookie settings are very simple, cookies are sent separately in the http header. The following example sets name and expires in the cookie:

#!/ usr/bin/python3

print ('Set-Cookie: name="Rookie Tutorial";expires=Wed, 28 Aug 2016 18:30:00 GMT')

print ('Content-Type: text/html')

print ()

print ("""

Rookie tutorial (runoob.com)

Cookie set OK!

""")

Save the above code to cookie_set.py and modify cookie_set.py permissions:

chmod 755 cookie_set.py

The above example uses Set-Cookie header information to set Cookie information, and other attributes of cookies are set in the optional options, such as expiration time Expires, domain name, and path. This information is set before "Content-type:text/html".

At this point, I believe that everyone has a deeper understanding of "how to set cookies," so you may wish to actually operate it! Here is the website, more related content can enter the relevant channels for inquiry, pay attention to us, continue to learn!

Tags: Information content examples tutorials rookie tutorials central settings rookies learning practicality deeper code interest domain name header practicality properties simple operation method time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Xiaomi MySQL Microsoft Shulou Tech Info Huawei