# Sessions info in a model (Noob)

**URL:** <https://www.ruby-forum.com/t/sessions-info-in-a-model-noob/116806>\
**Category:** Rails\
**Created:** [October 9, 2007, 11:21pm UTC](https://www.ruby-forum.com/t/sessions-info-in-a-model-noob/116806 "2007-10-09T23:21:07Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [October 9, 2007, 11:21pm UTC](https://www.ruby-forum.com/t/sessions-info-in-a-model-noob/116806/1 "2007-10-09T23:21:07Z")

</div>

I’ve got a variable called @current\_user that I currently create in  
each method of my controller. I’m thinking that I could reference it  
at a higher level, and then only have it once in my code, but it’s not  
clear to me where it should exist. I’ve got a bunch of objects that I  
create in my models that are reused throughout my controllers, but  
since this variable references session info, I can’t put it there.

Is there a simple solution to this (seems like there should be)?  
Perhaps it should live in the application controller?

Thanks for your help.

---

<div class="post-metadata">

**Author:** ![bob](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/ea666f/32.png) [@bob](https://www.ruby-forum.com/u/bob)\
**Post date:** [October 10, 2007, 7:00am UTC](https://www.ruby-forum.com/t/sessions-info-in-a-model-noob/116806/2 "2007-10-10T07:00:23Z")

</div>

I would recommend installing the restful\_authentication plugin in a  
new project and study how they do it. If you do this you will likely  
drop your customized solution and simply use the plugin. It’s very  
well done and would be a lot of work on your part to recreate. There  
are some very easy instructions and it only takes a few minutes to  
setup what you need for basic authentication. Then you can easily  
extend your application to provided whatever authentication and  
authorization you need. No need to reinvent the wheel here.

[http://agilewebdevelopment.com/plugins/restful\_authentication](http://agilewebdevelopment.com/plugins/restful_authentication)
