2006年04月30日 星期日 21:31
登陆后.存在一个用户关闭浏览器
又开启,又访问访问网页的问题
这时又需要去核对session
在limodou的django step by step中
他是用这样的方法解决的:
from django.http import HttpResponseRedirect
from django.shortcuts import render_to_response
def login(request):
username = request.POST.get('username', None)
if username:
request.session['username'] = username
username = request.session.get('username', None)
if username:
return render_to_response('login.html', {'username':username})
else:
return render_to_response('login.html')
def logout(request):
try:
del request.session['username']
except KeyError:
pass
return HttpResponseRedirect("/login/")
但如果多用户使用,多个session都赋给request.session['username'] 是行不通的
在django中多使用了一个SESSION_KEY的东西
我询问过limodou兄,可他说他也不很了解
我想请教大牛 是否有什么思路来解决此后的访问 session判断和核对?
谢谢
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060430/19e90eb8/attachment.html
2006年04月30日 星期日 21:52
不知道,我实验mod_python时,其中的Session在win32下默认使用MemorySession。其中就是不管timeout设的多长,如果用户关闭浏览器,Session就会消失。而且就算在一台电脑上,不同的浏览器进程都是拥有不同的Session的,而且互不干扰,运行的还不错。 Django有几种不同的底层实现,如果是用mod_python的话,那么MemorySession可以参考一下。 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.exoweb.net/pipermail/python-chinese/attachments/20060430/d498ff82/attachment.htm
Zeuux © 2025
京ICP备05028076号