def main(req):
username = req.session.get('username',None)
try :
print req.session['username']
print req.session.session_key
print '----------------'
except:
try:
req.session['username']
return render_to_response('main.html')
except:
try:
a=req.POST['username']
if (check_user(req.POST['username'],req.POST['password'])== 1):
req.session['username']=req.POST['username']
print req.encoding
return render_to_response('main.html')
else:
response = "用户名或密码错误"
return HttpResponse(response)
#return redirect('/index/')
except:
return redirect('/index/')
def index(req):
try:
req.session['username']
print req.session.session_key
return render_to_response('main.html')
except:
return render_to_response('index.html')