标签:style blog class code c java
设置Cookies response.set_cookie("cookie_key","value")
获取Cookies value = request.COOKIES["cookie_key"]
删除Cookies
response.delete_cookie("cookie_key",path="/",domain=name)
检测Cookies if "cookie_name" is request.COOKIES
例子:
def test_cookies(request): if "test" in request.COOKIES: temp=request.COOKIES[‘test‘] return HttpResponse("cookies="+temp) else: response = HttpResponse("test") response.set_cookie("test","123456789") return response
设置Sessions值 request.session[‘session_name‘] ="admin"
获取Sessions值 session_name = request.session["session_name"]
删除Sessions值 del request.session["session_name"]
检测是否操作session值 if "session_name" is request.session :
def test_sessions(request): if "test" in request.session: temp=request.session[‘test‘] return HttpResponse("session="+temp) else: request.session[‘test‘]=‘123456789‘ response = HttpResponse("abcdef") return response
cookies和sessions,布布扣,bubuko.com
标签:style blog class code c java
原文地址:http://www.cnblogs.com/sklww/p/3730136.html