Hello, Please help! I ran into a problem that session[:user_id] seems lost. The session[:user_id] is set during user''s login. Other pages have "before_filter :login_required". The method "login_required" is defined in ApplicationController to check if session[:user_id] exists. However, after user logs in successfully (I can see the printed user_id), and when bringing other pages which call login_required, the session[:user_id] becomes empty. I am using rails 1.2.2 and gem version is also 1.2.2. active_record_store is used for session storage. Can anyone shed some light on this problem? Thanks a lot! Wendong --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Are you sure the value is empty and that it''s just not a display issue on the other pages? And is the session still in your db? If those are good can you post some code so we can get a better idea what''s going on? Bryan http://www.workchest.com Workchest.com - Freelance jobs of every type You''re worth something at Workchest.com. On 2/7/07, WDZ <wendong.zhu-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > Hello, > > Please help! I ran into a problem that session[:user_id] seems lost. > The session[:user_id] is set during user''s login. Other pages have > "before_filter :login_required". The method "login_required" is > defined in ApplicationController to check if session[:user_id] exists. > However, after user logs in successfully (I can see the printed > user_id), and when bringing other pages which call login_required, the > session[:user_id] becomes empty. > > I am using rails 1.2.2 and gem version is also 1.2.2. > active_record_store is used for session storage. > > Can anyone shed some light on this problem? > > Thanks a lot! > > Wendong > > > > >--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks Bryan for your help. Yes, I am sure the value is empty, not display issue. The session is still in db (sessions table). Here is part of code: class IndexController < ApplicationController ........... def process_student_login if user = User.sauthenticate(params[:user]) if user.active? session[:uid] = user.id logger.info("session uid = #{session[:uid]}") # it prints out uid successfully .............. end end class ApplicationController < ActionController::Base before_filter :set_user def set_user logger.info("in set_user: session uid = #{session[:uid]}") # it prints out nil @user = User.find(session[:uid]) if @user.nil? && session[:uid] end def login_required logger.info("in login_required: session uid #{session[:uid]}") # it prints out nil return true if @user access_denied return false end class Myaccount::IndexController < ApplicationController before_filter :login_required # always fails and returns false ............ end --Wendong On Feb 7, 8:59 pm, "Bryan Tec" <progli...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Are you sure the value is empty and that it''s just not a display issue on > the other pages? > And is the session still in your db? > > If those are good can you post some code so we can get a better idea what''s > going on? > > Bryanhttp://www.workchest.com > Workchest.com - Freelance jobs of every type > You''re worth something at Workchest.com. > > On 2/7/07, WDZ <wendong....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Hello, > > > Please help! I ran into a problem that session[:user_id] seems lost. > > The session[:user_id] is set during user''s login. Other pages have > > "before_filter :login_required". The method "login_required" is > > defined in ApplicationController to check if session[:user_id] exists. > > However, after user logs in successfully (I can see the printed > > user_id), and when bringing other pages which call login_required, the > > session[:user_id] becomes empty. > > > I am using rails 1.2.2 and gem version is also 1.2.2. > > active_record_store is used for session storage. > > > Can anyone shed some light on this problem? > > > Thanks a lot! > > > Wendong--~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---