- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How do cookies work in Python CGI Programming?
Using Cookies in CGI
HTTP protocol is a stateless protocol. For a commercial website, it is required to maintain session information among different pages. For example, one user registration ends after completing many pages. How to maintain user's session information across all the web pages?
In many situations, using cookies is the most efficient method of remembering and tracking preferences, purchases, commissions, and other information required for better visitor experience or site statistics.
How Cookies work
Your server sends some data to the visitor's browser in the form of a cookie. The browser may accept the cookie. If it does, it is stored as a plain text record on the visitor's hard drive. Now, when the visitor arrives at another page on your site, the cookie is available for retrieval. Once retrieved, your server knows/remembers what was stored.
Cookies are a plain text data record of 5 variable-length fields −
Expires − The date the cookie will expire. If this is blank, the cookie will expire when the visitor quits the browser.
Domain − The domain name of your site.
Path − The path to the directory or web page that sets the cookie. This may be blank if you want to retrieve the cookie from any directory or page.
Secure − If this field contains the word "secure", then the cookie may only be retrieved with a secure server. If this field is blank, no such restriction exists.
Name=Value − Cookies are set and retrieved in the form of key and value pairs.
- How to setup cookies in Python CGI Programming?
- How to retrieve cookies in Python CGI Programming?
- How to do CGI programming in Python?
- Using Cookies in CGI in Python
- How do we do a file upload using Python CGI Programming?
- How cookies work in JSP?
- How to configure Apache for Python CGI Programming?
- How to work with cookies in Selenium with python?
- What are environment variables available in Python CGI Programming?
- How do Python modules work?
- What are the modules required for CGI programming in Python?
- How to write first Hello World program using CGI programming in Python?
- How do nested functions work in Python?
- How do Python dictionary hash lookups work?