会话被 django-all auth 重置
我正在使用 django all auth 登录我的网站。我想将一些会话变量从一个视图传递到另一个视图,但是当我通过 allauth 进入登录页面时,我的会话变量以某种方式被重置。当我进入登录页面时,会话是否被破坏? 如果是,如何将变量从一个视图传递到另一个视图?
view1
request.session['redirect-url'] = request.get_full_path()
path = request.session['redirect-url']
view2 (在登录视图中)
session_url = request.session.get('redirect-url' , None)
if session_url:
success_url = session_url
del request.session['redirect-url']
我还在我网站的其他页面上检查了此会话变量,并且它正在正确传递。但当我进入登录页面时正在重置。为什么?
我检查了 login
视图,没有明确的语句清除会话变量。
I am using django all auth for login on my website. I want to pass some session variables from one view to the other, but when I go to login page through allauth, my session variable is somehow being reset. Is the session being destroyed when I go to the login page?
If yes, how can I pass my variables from one view to the other?
view1
request.session['redirect-url'] = request.get_full_path()
path = request.session['redirect-url']
view2 (in login view )
session_url = request.session.get('redirect-url' , None)
if session_url:
success_url = session_url
del request.session['redirect-url']
I also check this session variable on other pages of my site and it is being passed correctly. But is being reset when i got to my login page. Why?
I have checked the login
view and there is no explicit statement that clears the session variable.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
因为您在登录视图中定义了
del
。del
清除会话变量。Because you define
del
in your login view.del
clears the session variable.