Rails session ID

145 views
Skip to first unread message

Tim Slattery

unread,
Aug 14, 2012, 10:59:15 AM8/14/12
to rubyonra...@googlegroups.com
I'm trying to retrieve the session ID in rails. I found a web page
that said to use

session.session_id

But when I do that, I get:

undefined method `session_id' for
#<Rack::Session::Abstract::SessionHash:0x2e14c5>

What do I need to do?

--
Tim Slattery
Slatt...@bls.gov

tomkins

unread,
Aug 14, 2012, 12:04:02 PM8/14/12
to rubyonra...@googlegroups.com, slatt...@bls.gov
Try request.session_options[:id]

Hassan Schroeder

unread,
Aug 14, 2012, 1:33:24 PM8/14/12
to rubyonra...@googlegroups.com
On Tue, Aug 14, 2012 at 7:59 AM, Tim Slattery <Slatt...@bls.gov> wrote:
> I'm trying to retrieve the session ID in rails. I found a web page
> that said to use
>
> session.session_id
>
> But when I do that, I get:
>
> undefined method `session_id' for
> #<Rack::Session::Abstract::SessionHash:0x2e14c5>
>
> What do I need to do?

Show the code that's causing that error message, plus the versions
of both Ruby and Rails. At least for starters :-)

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
http://about.me/hassanschroeder
twitter: @hassan
Message has been deleted

Jordon Bedwell

unread,
Aug 14, 2012, 11:53:14 AM8/14/12
to rubyonra...@googlegroups.com
On 08/14/2012 09:59 AM, Tim Slattery wrote:
> I'm trying to retrieve the session ID in rails. I found a web page
> that said to use
>
> session.session_id
>
> But when I do that, I get:
>
> undefined method `session_id' for
> #<Rack::Session::Abstract::SessionHash:0x2e14c5>
>
> What do I need to do?

Session is a hash as the error states. So do session['session_id'].

Tim Slattery

unread,
Aug 16, 2012, 8:57:20 AM8/16/12
to rubyonra...@googlegroups.com
tomkins <j.to...@live.com> wrote:

>Try request.session_options[:id]

Thanks to all who replied. The code above worked. No doubt some of the
other suggestions would have also.

Many thanks from someone trying to figure out Ruby and Rails at the
same time!

--
Tim Slattery
Slatt...@bls.gov

Reply all
Reply to author
Forward
0 new messages