I have used restful_authentication to implement a login system and it works fine except that every couple of weeks I can’t login when I use IE; it works fine when I use other browsers! The problem goes away after a few hours! It seems to me somehow sometimes after logging in, the session variable is not set! I have the following code for create action in my sessions_controller.rb def create logout_keeping_session! user = User.authenticate(params[:login], params[:password]) if user self.current_user = user new_cookie_flag = (params[:remember_me] == "1") handle_remember_cookie! new_cookie_flag redirect_to ''/sessions/home'' else note_failed_signin @login = params[:login] @remember_me = params[:remember_me] redirect_to "/sessions/login" end end Can redirect_to ''/sessions/home'' cause the problem with the session variable and erase its value? -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Frederick Cheung
2011-Jan-04 11:32 UTC
Re: Interaction between redirect_to and session variable
On Jan 4, 8:48 am, Fc Ca <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have used restful_authentication to implement a login system and it > works fine except that every couple of weeks I can’t login when I use > IE; it works fine when I use other browsers! The problem goes away after > a few hours! It seems to me somehow sometimes after logging in, the > session variable is not set! >apparently IE has quirks when setting a cookie at the same time as redirecting. Some say that setting a P3P header help (see comments on http://jhottengineering.blogspot.com/2009/02/ie-post-and-redirect-errors.html for example) Fred> I have the following code for create action in my sessions_controller.rb > > def create > logout_keeping_session! > user = User.authenticate(params[:login], params[:password]) > > if user > self.current_user = user > new_cookie_flag = (params[:remember_me] == "1") > handle_remember_cookie! new_cookie_flag > > redirect_to ''/sessions/home'' > else > note_failed_signin > @login = params[:login] > @remember_me = params[:remember_me] > > redirect_to "/sessions/login" > end > end > > Can redirect_to ''/sessions/home'' cause the problem with the session > variable and erase its value? > > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Thank you, Fred! I looked at the page that you mentioned and some related pages. I have implemented several possible solutions and will try them next time the bug is activated and will post the result here for others who may face this problem in future. Frederick Cheung wrote in post #972206:> On Jan 4, 8:48am, Fc Ca <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> I have used restful_authentication to implement a login system and it >> works fine except that every couple of weeks I cant login when I use >> IE; it works fine when I use other browsers! The problem goes away after >> a few hours! It seems to me somehow sometimes after logging in, the >> session variable is not set! >> > apparently IE has quirks when setting a cookie at the same time as > redirecting. Some say that setting a P3P header help (see comments on > http://jhottengineering.blogspot.com/2009/02/ie-post-and-redirect-errors.html > for example) > > Fred-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.