0

I am trying to get the active session_id of a user after the user successfully logs in. The session_id needs to be stored in a field of User model for later operations. I'm using devise with activerecord-session_store.

Tried to override some devise methods after sign_in but didn't help.

Pragun
  • 1,123
  • 8
  • 20

1 Answers1

0
  • Try this in controller
  Warden::Manager.after_set_user do |user, auth, opts|
    if (opts[:scope] == :user && opts[:event] == :set_user)
      # code
    end  
  end
  • you can get session from session['session_id']

Reference: Ruby on Rails Devise code after login

Ash
  • 105
  • 1
  • 11
  • it did not help. session['session_id'] was not accessible in the block. referred to this instead. https://stackoverflow.com/questions/18609844/rails-activerecord-store-and-new-session thanks! – Pragun Jul 26 '19 at 04:48