# Problem with session

**URL:** <https://www.ruby-forum.com/t/problem-with-session/125248>\
**Category:** Rails\
**Created:** [January 7, 2008, 2:21pm UTC](https://www.ruby-forum.com/t/problem-with-session/125248 "2008-01-07T14:21:37Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [January 7, 2008, 2:21pm UTC](https://www.ruby-forum.com/t/problem-with-session/125248/1 "2008-01-07T14:21:37Z")

</div>

Hi,  
I have problem when i tried to logging logging successfull,  
but when tried to find out the current cuser details by session it  
always says nil

code for loging:-

@user = User.new(params[:user])  
#session[:user\_id] = nil

```
case request.method
when :post

  respond_to do |format|
    if @current_user = User.authenticate(@user.email, params[:user]

```

[:hashed\_password])  
session[:user\_id] = @current\_user.id  
flash[:notice] = “user login successfully !!!”  
format.html { redirect\_to(users\_path) }  
else  
flash[:notice] = " better try next time !!!"  
format.html { render :action =\> “index” }  
end

i want to fetch user details from user table by from user controller  
Couldn’t find User with ID=2

but the current user id is not 2, it always take id 2  
code:-  
@user=User.find(session[:user\_id])

Thank’s  
ajit
