# Access session hash in behaviours

**URL:** <https://www.ruby-forum.com/t/access-session-hash-in-behaviours/64996>\
**Category:** Radiant CMS\
**Created:** [August 15, 2006, 4:32pm UTC](https://www.ruby-forum.com/t/access-session-hash-in-behaviours/64996 "2006-08-15T16:32:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Saint\_Berry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2acd7d/32.png) [@Saint\_Berry](https://www.ruby-forum.com/u/Saint_Berry)\
**Post date:** [August 15, 2006, 4:32pm UTC](https://www.ruby-forum.com/t/access-session-hash-in-behaviours/64996/1 "2006-08-15T16:32:04Z")

</div>

Hey All,

I have been having a little play around with behaviours trying to get a  
better feel for how things work. Specifically I am working on a login  
form  
behaviour using McCray’s MalierBehaviour as a loose guide to see how  
things  
work.

I face problems when trying to access the session hash to see if a user  
has  
been logged in successfully or not (undefined variable or method error).

My guess is (and this could be way wrong) that I cannot access the  
session  
hash as I would in a controller and therefore I need to include part of  
the  
rails framework in the behaviour to allow me to do so. This line of code  
in  
the MalierBehaviour led me to think that

class MailerTagError \< StandardError; end

although I must confess I am a little new to ruby and rails and don’t  
quite  
get whats going on there.

If anyone could point me in the correct direction it would be much  
appriciated.

Cheers.

---

<div class="post-metadata">

**Author:** ![Saint\_Berry](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/2acd7d/32.png) [@Saint\_Berry](https://www.ruby-forum.com/u/Saint_Berry)\
**Post date:** [August 15, 2006, 5:47pm UTC](https://www.ruby-forum.com/t/access-session-hash-in-behaviours/64996/2 "2006-08-15T17:47:56Z")

</div>

I’m kind of in the same boat that you are and one thing I have learned  
is that you have access to the request object and the session with it.  
But you have to uncomment line 4 in SiteController (session :off).

Hope it helps,

Adrian M.
