Rails2.2.2アプリでsession_idを取得しようとしています
Railsのドキュメントを調べて、構文的にいくつかの異なることを試しました。
request.inspectまたはsession.inspectを実行すると、@session_idに値があることがわかります
@session_id="BAh7CjoMd...",
それでも、次のすべてはnilを返します。
request.session[:session_id].inspect
session[:session_id].inspect
session['session_id'].inspect
session.inspectからの出力:
#<CGI::Session:0x104dff278
@write_lock=true,
@data={
:user_id=>nil,
:privilege_id=>nil,
:after_login=>{"action"=>"index", "controller"=>"home"},
:csrf_id=>"34a78413704ac92ee0eb276339b1af76", "flash"=>{}
},
@new_session=false,
@dbprot=[
#<CGI::Session::CookieStore:0x104dfe8a0
@secret="ee912af8f735b1acf19...",
@data={:
user_id=>nil,
:privilege_id=>nil,
:after_login=>{"action"=>"index", "controller"=>"home"},
:csrf_id=>"34a78413704ac92ee0eb276339b1af76", "flash"=>{}},
@digest="SHA1",
@original="BAh7CjoMd...",
@cookie_options={
"name"=>"_vendor_sandbox_session",
"http_only"=>true,
"secure"=>nil,
"expires"=>nil,
"domain"=>nil,
"path"=>"/"},
@session=#<CGI::Session:0x104dff278 ...>>],
@dbman=#<CGI::Session::CookieStore:0x104dfe8a0
@secret="ee912af8f735b1acf19...",
@data={
:user_id=>nil,
:privilege_id=>nil,
:after_login=>{
},
:csrf_id=>"34a78413704ac92ee0eb276339b1af76",
"flash"=>{}},
@digest="SHA1",
@original="BAh7CjoMd...",
@cookie_options={
"name"=>"_vendor_sandbox_session",
"http_only"=>true,
"secure"=>nil,
"expires"=>nil,
"domain"=>nil,
"path"=>"/"
},
@session=#<CGI::Session:0x104dff278 ...>>,
@session_id="BAh7CjoMd...",
@cgi=#<CGI:0x104f73c30
@cookies={
"_vendor_sandbox_session"=>["BAh7CjoMd..."],
},
@params={},
@output_hidden=nil,
@multipart=false,
@env_table={
"REQUEST_METHOD"=>"GET",
"SERVER_NAME"=>"localhost",
"SERVER_PORT"=>"3000",
"HTTP_CONNECTION"=>"keep-alive",
"QUERY_STRING"=>nil,
"PATH_INFO"=>"/login",
"SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/1.8.7/2012-02-08)",
"REQUEST_URI"=>"http://localhost:3000/login",
"HTTP_ACCEPT_LANGUAGE"=>"en-US,en;q=0.5",
"GATEWAY_INTERFACE"=>"CGI/1.1",
"REMOTE_HOST"=>"127.0.0.1",
"REMOTE_USER"=>nil,
"SERVER_PROTOCOL"=>"HTTP/1.1",
"HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/20100101 Firefox/17.0",
"HTTP_CACHE_CONTROL"=>"no-cache",
"HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"REMOTE_ADDR"=>"127.0.0.1",
"HTTP_COOKIE"=>_vendor_sandbox_session=BAh7CjoMdXNlcl9p...",
"HTTP_PRAGMA"=>"no-cache",
"HTTP_ACCEPT_ENCODING"=>"gzip, deflate",
"HTTP_HOST"=>"localhost:3000"},
@output_cookies=nil,
@stdin=#<StringIO:0x104f73c58