# Reset session inside a model?

**URL:** <https://www.ruby-forum.com/t/reset-session-inside-a-model/68978>\
**Category:** Rails\
**Created:** [September 17, 2006, 9:16pm UTC](https://www.ruby-forum.com/t/reset-session-inside-a-model/68978 "2006-09-17T21:16:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [September 17, 2006, 9:16pm UTC](https://www.ruby-forum.com/t/reset-session-inside-a-model/68978/1 "2006-09-17T21:16:20Z")

</div>

Can I reset / delete the session from a model (rather than from a  
controller)?

When a visitor to my site logs out, all the information they entered  
into the DB and files created while they were using the site are deleted  
and then I reset their session. I’m trying to move the cleanup from my  
controller into my model.

Everything works fine in the controller, but I’m getting an " undefined  
local variable or method ‘reset\_session’ " error when I call  
reset\_session in the model.

Thanks!  
Bill

---

<div class="post-metadata">

**Author:** ![wpwood](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/w/d6d6ee/32.png) [@wpwood](https://www.ruby-forum.com/u/wpwood)\
**Post date:** [September 18, 2006, 4:36pm UTC](https://www.ruby-forum.com/t/reset-session-inside-a-model/68978/2 "2006-09-18T16:36:12Z")

</div>

Its probobly not the best idea to have session handling inside your  
business logic.

Instead, you could implement a “reset” method for models that the user  
will be using throughout a session and call it from the appropriate  
action in your controller.

#controller file…  
class MyController  
def logout  
@userobject.reset  
reset\_session  
end  
end

hope that helps.

-Sean
