Django Session處理
阿新 • • 發佈:2019-02-18
def setSession(request):
msg=''
try:
request.session['userName']='lushijie'
msg='成功設定Session'
except Exception:
msg='設定Session失敗'
return HttpResponse(msg)
def getSession(request):
msg=''
try:
msg=request.session['userName']
except Exception:
msg='沒有設定session'
return HttpResponse(msg);
def delSession(request):
msg=''
try:
del request.session['userName']
msg='成功刪除Session'
except Exception:
msg='刪除Session失敗'
return HttpResponse(msg)
msg=''
try:
request.session['userName']='lushijie'
msg='成功設定Session'
except Exception:
msg='設定Session失敗'
return HttpResponse(msg)
def getSession(request):
msg=''
try:
msg=request.session['userName']
except Exception:
msg='沒有設定session'
return HttpResponse(msg);
def delSession(request):
msg=''
try:
del request.session['userName']
msg='成功刪除Session'
except Exception:
msg='刪除Session失敗'
return HttpResponse(msg)