python Djangp cookies的使用

上一篇 / 下一篇  2016-12-08 17:25:14 / 个人分类:python

fromdjango.shortcutsimportrender
fromdjango.httpimportHttpResponse,HttpResponseRedirect
def
index(request):
returnrender(request,'index.html')

deflogin_action(request):
ifrequest.method=='POST':
username = request.POST.get('username','')
password = request.POST.get('password','')
ifusername =='admin'andpassword =='123':
res = HttpResponseRedirect('/event_manage/')
res.set_cookie('user',username,3600)
returnres

else:
returnrender(request,'index.html',{"error":"Your username or password error"})

defevent_manage(request):
username = request.COOKIES.get('user','')
returnrender(request,'event_manage.html',{'user':username})

TAG: cookies Python python

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

Open Toolbar