
本文共 3868 字,大约阅读时间需要 12 分钟。
HTTP������������������������������������������
������������������������
HTTP���������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������HTTP������������TCP���������������������������������������������������������������������������������������������������
���������������������������
������HTTP���������������������������Web���������������������������������������������������
- ������������������������������������������������������������������������������������������������������������
- ���������������������������������������������������������������������������������������������������������
- ���������������������������������������������������������������������������������������������������
���������������������������
������������������������������������������������������
1. ������������������������ - Cookie
Cookie���������������������������������������������������������������������������������������������������Cookie���������������������������������������������Cookie������������������������������������������������������������������������������������������������������������
Cookie������������
- ������������������������������������������������������
- ������������������������������������������SameSite��������������������� cookie ���������
- ���������������������������������������������������������������������������������������������������
2. ��������������������������� - Session
Session���������������������������������������������������������������������������������������������������Session ID���������������������������Cookie���������������������������������JavaScript������������������������������������������������������������
Session������������
- ������������������������������������
- ���������������������Session������������������������������������������������������������
- ���������������������������������������������������������������������
������������������������
������������������������������������
������������������������������
���������
- ������������������������������������������������ Cookie ������������������������������������������������������
- ������������������������������������������������������������������������������������ Cookie ��� Session ���������������������������������
- ������������������������������������������������������������������������
Cookie���������������
������Cookie���
��� Flask ������������������������������������������ Cookie���
from flask import make_response@app.route('/cookie')def set_cookie(): resp = make_response('������������ Cookie ���������') resp.set_cookie('username', 'itcast') return resp
���������������������
������������ max_age
������������ Cookie ������������������
@app.route('/cookie')def set_cookie(): response = make_response('hello world') response.set_cookie('username', 'itheima', max_age=3600) return response
������Cookie���
��� Flask ������������������������������������ Cookie���
from flask import Flask, request@app.route('/request')def resp_cookie(): username = request.cookies.get('username') return username
������
HTTP ������������������������������������������������������������������������������������������������������������������������������������������������������������������ Cookie ������������������������ Session ���������������������������������������������������������������������������������������������
发表评论
最新留言
关于作者
