# Rendering a View Creates Session

**URL:** <https://www.ruby-forum.com/t/rendering-a-view-creates-session/169806>\
**Category:** Rails\
**Created:** [June 9, 2009, 2:25am UTC](https://www.ruby-forum.com/t/rendering-a-view-creates-session/169806 "2009-06-09T02:25:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [June 9, 2009, 2:25am UTC](https://www.ruby-forum.com/t/rendering-a-view-creates-session/169806/1 "2009-06-09T02:25:50Z")

</div>

I have a controller action that I am disabling via: “session :off”

I am noticing that a session is created when this action’s view is  
rendered. Specifically, a session is created when this line in my  
view code is executed:

\<%= image\_tag @image\_path %\>

Taking out this line leads to no session being created as desired.

Any ideas how to fix this?

Thanks in advanced

---

<div class="post-metadata">

**Author:** ![randall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/b38774/32.png) [@randall](https://www.ruby-forum.com/u/randall)\
**Post date:** [June 9, 2009, 7:02am UTC](https://www.ruby-forum.com/t/rendering-a-view-creates-session/169806/2 "2009-06-09T07:02:31Z")

</div>

I should clarify that sessions for that particular action is disabled  
via “session :off, :only =\> ‘no\_session\_action’”

When I disable sessions globally by putting “session :off” in  
application.rb, no session is created when the client browser loads  
the view rendered by no\_session\_action.

Also, sessions get created for nonsense urls that lead to the 404  
page, which is something I do not want to happen.

So it appears what I need to do is detect calls that the server does  
not respond to (nonsense urls, browser loading images) and not create  
sessions for these calls.

If anybody knows how I can do this, I would really appreciate the  
help.

Thanks!
