# Is the session hash available to tests or the rails console?

**URL:** <https://www.ruby-forum.com/t/is-the-session-hash-available-to-tests-or-the-rails-console/123440>\
**Category:** Rails\
**Created:** [December 17, 2007, 7:59pm UTC](https://www.ruby-forum.com/t/is-the-session-hash-available-to-tests-or-the-rails-console/123440 "2007-12-17T19:59:57Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [December 17, 2007, 7:59pm UTC](https://www.ruby-forum.com/t/is-the-session-hash-available-to-tests-or-the-rails-console/123440/1 "2007-12-17T19:59:57Z")

</div>

My guess is that the answer is no because the session hash is  
available only if you’re storing a cookie, and you can’t store a  
cookie if you’re using the rails console or using the built-in testing  
functionality. Can someone confirm that this is correct?

---

<div class="post-metadata">

**Author:** ![eggman2001](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/51bf81/32.png) [@eggman2001](https://www.ruby-forum.com/u/eggman2001)\
**Post date:** [December 17, 2007, 8:05pm UTC](https://www.ruby-forum.com/t/is-the-session-hash-available-to-tests-or-the-rails-console/123440/2 "2007-12-17T20:05:12Z")

</div>

In tests:  
Assuming you have this in your setup method: @request =  
ActionController::TestRequest.new  
You can access the session hash via  
@request.session
