# Session\[:user\]

**URL:** <https://www.ruby-forum.com/t/session-user/109575>\
**Category:** Rails\
**Created:** [July 17, 2007, 12:45am UTC](https://www.ruby-forum.com/t/session-user/109575 "2007-07-17T00:45:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![PatRoy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ec8ea/32.png) [@PatRoy](https://www.ruby-forum.com/u/PatRoy)\
**Post date:** [July 17, 2007, 12:45am UTC](https://www.ruby-forum.com/t/session-user/109575/1 "2007-07-17T00:45:25Z")

</div>

Hi,

When I log in from a form post to session/create there’s a call to  
User.authenticate (which in turn puts a :user variable in the session  
from the self.current\_user call.

My issue is when I call self.current\_user = User.authenticate(…)  
from somewhere else and I redirect… I lose my session variable. How  
could this happen?

---

<div class="post-metadata">

**Author:** ![PatRoy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ec8ea/32.png) [@PatRoy](https://www.ruby-forum.com/u/PatRoy)\
**Post date:** [July 17, 2007, 10:48am UTC](https://www.ruby-forum.com/t/session-user/109575/2 "2007-07-17T10:48:52Z")

</div>

PatRoy wrote:

> Hi,
> 
> When I log in from a form post to session/create there’s a call to  
> User.authenticate (which in turn puts a :user variable in the session  
> from the self.current\_user call.
> 
> My issue is when I call self.current\_user = User.authenticate(…)  
> from somewhere else and I redirect… I lose my session variable. How  
> could this happen?

you should post your code for more informative detail, but this could  
also be an issue of your browser …

?

---

<div class="post-metadata">

**Author:** ![PatRoy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ec8ea/32.png) [@PatRoy](https://www.ruby-forum.com/u/PatRoy)\
**Post date:** [January 18, 2009, 7:41am UTC](https://www.ruby-forum.com/t/session-user/109575/3 "2009-01-18T07:41:18Z")

</div>

Hi,

I’m having the same problem. Were you able to solve this?

Thanks for your help.

PatRoy wrote:

> Hi,
> 
> When I log in from a form post to session/create there’s a call to  
> User.authenticate (which in turn puts a :user variable in the session  
> from the self.current\_user call.
> 
> My issue is when I call self.current\_user = User.authenticate(…)  
> from somewhere else and I redirect… I lose my session variable. How  
> could this happen?

---

<div class="post-metadata">

**Author:** ![PatRoy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/3ec8ea/32.png) [@PatRoy](https://www.ruby-forum.com/u/PatRoy)\
**Post date:** [January 18, 2009, 7:52am UTC](https://www.ruby-forum.com/t/session-user/109575/4 "2009-01-18T07:52:15Z")

</div>

Maybe somewhere has the code “reset\_session”  
or “session[:user] = nil”

On Sun, Jan 18, 2009 at 2:41 PM, Jason Member \<  
removed\_email\_address@domain.invalid\> wrote:

> > 
> 
> >

–  
TWRUG Blog:  
[http://blog.rubyonrails.org.tw](http://blog.rubyonrails.org.tw)

CFC on Rails:

> **[CFC on Rails](http://zusocfc.blogspot.com)**
>
> 火車請別撞我

Only two surfaces of a box:  
[http://blog.pixnet.net/zusocfc](http://blog.pixnet.net/zusocfc)
