
:remember_me option not saving with UserSession.new
Reported by c00lryguy | July 11th, 2009 @ 03:53 AM
View
- if current_user
%p= "Signed in as " << current_user.email << "!"
%p= current_user_session.remember_me?
- else
%h1 Login
%p
- form_for :login_info, :url => login_path do |f|
= f.label :email
= f.text_field :email
= f.label :password
= f.password_field :password
= f.submit "Submit"
= f.check_box :remember_me
= f.label :remember_me
Controller
class UserSessionsController < ApplicationController
before_filter :require_no_user, :only => :create
before_filter :require_user, :only => :destroy
def create
user_session = UserSession.new(params[:login_info])
if user_session.save
flash[:notice] = "Logged in!"
redirect_to home_path
else
flash[:error] = "Error: Login unsuccessful!"
redirect_to home_path
end
end
def destroy
current_user_session.destroy
flash[:notice] = "Logged out!"
redirect_to home_path
end
end
Problem
Now when I login with the option 'Remember me?' checked, Rails
passes:
Processing UserSessionsController#create (for 127.0.0.1 at 2009-07-11 03:39:15) [POST]
Parameters:
{"commit"=>"Submit", "action"=>"create", "controller"=>"user_sessions",
"login_info"=>{"password"=>"[FILTERED]", "remember_me"=>"1", "email"=>"c00lryguy@gmail.com"}}
But the View displays:
Signed in as c00lryguy@gmail.com!
false
No matter how hard I try I can't get the current_user_session to remember the remember_me option.
Comments and changes to this ticket
-
Ben Johnson July 12th, 2009 @ 09:38 PM
- State changed from new to open
That's strange. The remember_me feature uses a cookie. Are you sure that cookies are properly being created? Try doing a simple test where you expire a cookie in the future, close your browser, and see if you can still retrieve that cookie. I can't tell you how many times people have an issue with authlogic when their cookies aren't working properly.
I'm using the remember_me function on a number of sites I manage and all are working great.
Hope this helps.
-
Philippe René July 15th, 2009 @ 11:03 AM
I'm having the same problem here but I can get the remember_me to be true on the current_user_session.
I don't have any remeber_me cookie created either.... will keep work on it...
Thanks
-
Ben Johnson August 7th, 2009 @ 06:20 PM
- State changed from open to moved_to_github
[state:"moved_to_github" bulk edit command]
-
isoconsultation February 24th, 2020 @ 06:30 AM
Good. I really like this, I just found out about this. This was an incredibly wonderful article.
ISO Certification in Bahrain
ISO 9001 Certification in Bahrain -
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
Object based authentication solution that handles all of the non sense for you. It's as easy as ActiveRecord is with a database.