Search code examples
ruby-on-railssessiondevisewarden

Accessing the new session_id in devise after sign_in


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.


Solution

  • 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