登录后访问设计中的新session_id [英] Accessing the new session_id in devise after sign_in
问题描述
我正在使用devise&重写SessionsController#create以根据特定条件跟踪登录.
I am using devise & overriding SessionsController#create to track the login based on a specific condition.
即使执行sign_in(user)之后,在sign_in(user)之前的session [:session_id]的值也相同.
The value of session[:session_id] before sign_in(user) is same even after the execution of sign_in(user).
我想在数据库中存储新的session_id以便跟踪用户.但无法访问它.如何获得?
I would like to store the new session_id in DB in order to track the user. But unable to access it. How to get it?
在寻找它的同时,发现Devise使用Warden的set_user方法.但是即使那样,我也无法弄清楚该会话在Warden中的设置位置.
While looking for it, found that Devise uses set_user method of Warden. But even then, I could not figure out where the session is set in Warden.
推荐答案
找到以下问题的答案:
本杰明·辛克莱尔(Benjamin Sinclaire)的答案为我工作(尽管未标记为答案).只是将request.session_options替换为session.options
Answer by Benjamin Sinclaire worked for me (though it was not marked as answer). Just replaced session.options with request.session_options
这篇关于登录后访问设计中的新session_id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!