Set our cookies
def set_cookies(request):
Get the information sent by the postman
request refers to a request for information http
GET method is to get in the way we get the request data
The latter name is our key value inside the distal end, in front of the name is the variable in the received data we django
name=request.GET.get('name')
Http assigned to instantiate a coo
coo = HttpResponse ( 'I set operation cookies')
Set cookies
coo.set_cookies('cooke_name',name)
return coo
Get our cookies
def get_cookies(request):
The front end to get the information we pass over
request refers to information http request
doing=request.GET.get('doing')
COOKIES is the way we get the data in the manner requested
name=request.COOKIES.get('cooke_name')
cooke_name we django which variables receive data
return HttpResponse(name+doing)
Set session
def set_session(request):
name=request.GET.get('name')
Obtaining session
request.session['session_name']=name
return HttpResponse ( 'This is a process of setting the session')
def get_session(request):
doing=request.GET.get('doing')
name=request.session.get('session_name')
return HttpResponse(name+doing)
Transfer methods : get transmitted through the address bar, it is transmitted in clear text, insecurity, post packet transmission. Security is relatively high.
Transport length: get parameters length limit (limited by the url length), and post unlimited
GET and there is a significant difference between the POST, simply say:
GET generates a TCP packet; generating the POST two TCP packets