问题
I am using devise & overriding SessionsController#create to track the login based on a specific condition.
The value of session[:session_id] before sign_in(user) is same even after the execution of sign_in(user).
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?
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.
回答1:
Found the answer in the following question:
Rails ActiveRecord store and new session
Answer by Benjamin Sinclaire worked for me (though it was not marked as answer). Just replaced session.options with request.session_options
来源:https://stackoverflow.com/questions/32439212/accessing-the-new-session-id-in-devise-after-sign-in