我正在使用这个来登录用户:
def login_backend(request):
if request.method == 'POST':
username = request.POST['username']
password = request.POST['password']
user = authenticate(username=username, password=password)
if user is not None:
login(request, user)
request.session.set_expiry(300)
return HttpResponseRedirect('/overview/')
else:
return HttpResponseRedirect('/login_backend/')
else:
return render_to_response('login_backend.html', context_instance=RequestContext(request))
我希望会话在5分钟后过期,因此我在上面的视图中添加了request.session.set_expiry(300)
。但是会话从未过期。我做错了什么?