Hi there, I am trying to figure out how to have persistent sessions (with like a month until expiration) for my users, sort of like a "remember me" functionality but that is handled automatically on login. I am hoping I can get some help from someone who is more experienced with Rails. I am currently using a controller called "Sessions" to handle my session properties. This is what my controller looks like. def create @current_user = User.find_by_login_and_password( params[:login], params[:password]) if @current_user session[:user_id] = @current_user.id if session[:return_to] redirect_to session[:return_to] session[:return_to] = nil else redirect_to links_path end else render :action => ''new'' end end def destroy session[:user_id] = @current_user = nil end I have surfed around the internet looking for solutions but their is no real consistent method out there. Everyone seems to have a different opinion on how to manage sessions/cookies. I am hoping to not have to change my controller structure (by say installing a plug-in) and sticking with Sessions creation. Thank you in advance. -- 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.
Sent from my iPhone On Feb 27, 2010, at 7:16 PM, Michael Murillo <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hi there, > > I am trying to figure out how to have persistent sessions (with like a > month until expiration) for my users, sort of like a "remember me" > functionality but that is handled automatically on login. I am > hoping I > can get some help from someone who is more experienced with Rails. > > I am currently using a controller called "Sessions" to handle my > session > properties. > > This is what my controller looks like. > > def create > @current_user = User.find_by_login_and_password( > params[:login], params[:password]) > > if @current_user > session[:user_id] = @current_user.id > if session[:return_to] > redirect_to session[:return_to] > session[:return_to] = nil > else > redirect_to links_path > end > else > render :action => ''new'' > end > end > > def destroy > session[:user_id] = @current_user = nil > end > > I have surfed around the internet looking for solutions but their is > no > real consistent method out there. Everyone seems to have a different > opinion on how to manage sessions/cookies. I am hoping to not have to > change my controller structure (by say installing a plug-in) and > sticking with Sessions creation. > > Thank you in advance.Michael, I would recommend using Authlogic because it has a method, remember_me_for, that one can redefine in the user_session model to set the duration of time. Good luck, -Conrad> -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org > . > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en > . >-- 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.
> Michael, I would recommend using Authlogic because it has a method, > remember_me_for, that one can redefine in the user_session model to > set the duration of time. > > Good luck, > > -ConradI look into this but I am a bit concerned about whether there will be an overwriting or conflicts with my current models and controllers. Is is possible to install a plugin like Authlogic or restful_authentication with a current user and sessions model and controller? I have already created a very basic user and session system and my users are tied in to my voting model so I am hoping to not have to rebuild any of my database. If this is possible, do you know of a good tutorial for adding user management to an existing site with a more basic user management system? Thanks for the help. -- 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.
On Thu, Mar 4, 2010 at 8:55 AM, Michael Murillo <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> > > Michael, I would recommend using Authlogic because it has a method, > > remember_me_for, that one can redefine in the user_session model to > > set the duration of time. > > > > Good luck, > > > > -Conrad > > I look into this but I am a bit concerned about whether there will be an > overwriting or conflicts with my current models and controllers. Is is > possible to install a plugin like Authlogic or restful_authentication > with a current user and sessions model and controller? I have already > created a very basic user and session system and my users are tied in to > my voting model so I am hoping to not have to rebuild any of my > database. > > If this is possible, do you know of a good tutorial for adding user > management to an existing site with a more basic user management system? > >Michael, I would recommend reading the docs on the use of the gem which can be found here: http://github.com/binarylogic/authlogic Good luck, -Conrad> Thanks for the help. > > -- > 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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.