Ruby on Rails Sunday, January 22, 2012

Hai!

I have two controller. the one is first_controller and another one is
second_controller.

first_controller.rb

def login
.
.
if @user && @user.password == params[:user][:password]
session[:user_id] = @user.id
redirect_to :controller => "second_controller", :action => "index"
end
end

second_controller.rb

def index
if session[:user_id] != nil
logger.info" The user id is not null"
else
logger.info" The user id is null"
end
end

#=======Result
The user id is not null # 1st time
The user id is null # 2nd time
The user id is not null # 3rd time
The user id is not null # 4th time
The user id is null # 5th time
The user id is not null # 6th time
The user id is not null # 7th time
The user id is not null # 8th time
The user id is not null # 9th time
The user id is not null # 10th time
The user id is not null # 11th time
The user id is null # 12th time

Here my session variable id dynamic not a static. But i want static
value.
I hope this is session problem. help me.

Thanks for you.
bdeveloper01

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment