Cookies are frequently used in web applications to store data in browsers. The most frequent use case is user identification.
We are going to implement a very simple and insecure identification system based on cookies to show how to use them.
Cookies are frequently used in web applications to store data in browsers. The most frequent use case is user identification.
We are going to implement a very simple and insecure identification system based on cookies to show how to use them.
The http.cookies.SimpleCookie class provides all the facilities required to parse and generate cookies.
from web_06 import WSGIApplication
app = WSGIApplication()
import time
from http.cookies import SimpleCookie
@app.route('/identity')
def identity(req, resp):
identity = int(time.time())
cookie = SimpleCookie()
cookie['identity'] = &apos...