Finding the session id in rails 3

前端 未结 5 783
耶瑟儿~
耶瑟儿~ 2020-12-13 05:35

How can I get the current session id in rails 3?

I\'ve tried the following with no luck:

session[:session_id]
session[\'session_id\']
session[:id]
se         


        
5条回答
  •  萌比男神i
    2020-12-13 06:30

    If you need to see data written in Session store for given session id from Rails console you can:

    a = Rails.application.config.session_store.new(app, Rails.application.config.session_options)
    a.class # => ActionDispatch::Session::RedisStore
    a.get_session(ENV, '07319b2485be9ac4850664cd47cede38')
    
    
    # or a.find_session(ENV, '07319b2485be9ac4850664cd47cede38')
    

    app andENV are set when you start rails console, don't need to set those

    you can get the session_id via some a browser plugin dealing with cookies or (cookie inspector, cookies manager, ...)

提交回复
热议问题