0

how can i get the session_id inside application_controller. I am creating helper methods here in this controller to set session and read them later and I am able to read all session variables, cookies etc from the application_controller. The only exception is

session[:session_id] (variations tried - session[:id], session["id"], session["session_id"] and request.session_options[:id])

But none of these provide session_id value.

In my views session[:session_id] works fine. But in the application controller this is just not working.

Any help would be appreciated. I am obviously doing something wrong here.

deepinder
  • 131
  • 2
  • 8

1 Answers1

0

Did you forgot before_filter? It's works for me.

class ApplicationController < ActionController::Base
  protect_from_forgery

  before_filter :catch_session_id

  def catch_session_id
    binding.pry
  end
end

    14: def catch_session_id
 => 15:   binding.pry
    16: end

[1] pry(#<WelcomeController>)> session[:session_id]
=> "a7eca9eaaf21cff74c0d21713fcaad09"
ck3g
  • 5,829
  • 3
  • 32
  • 52