设计记住我没有存储cookie

发布于 2024-12-08 17:16:08 字数 1600 浏览 0 评论 0原文

我已经设置了一个简单的示例应用程序,它使用 devise 进行用户身份验证。

当我在登录时选择“记住我”复选框时,我会在控制台中看到以下内容:

由 Devise::SessionsController#create as HTML 处理 参数:{"commit"=>"登录", "authenticity_token"=>"Vm+2aWEmCRnnjdXAOpXdI5dGChUKlEcmfGNXNoGUkwc=", "utf8"=>"Г£ô", "user"=>{"remember_me"= >“1”,“密码” =>"[已过滤]", "电子邮件"=>"[电子邮件受保护] "}} ←[1m←[35m用户负载(1.0ms)←[0m SELECT "users".* FROM "users" WHERE "users"."email" = '[电子邮件受保护]' LIMIT 1 ←[1m←[36mAREL (1.0ms)←[0m ←[1mUPDATE "用户" SET "last_sign_in_at" = '2011-10-06 21:36:46.439511', "updated_at" = '2011-10-06 21:43 :59.298269', “登录计数 t" = 15, "current_sign_in_at" = '2011-10-06 21:43:59.297269' 其中 "users"."id" = 1←[0m

我的帖子控制器中有以下内容:

before_filter :authenticate_user!

但是,当我关闭浏览器时并再次打开它,我被迫再次登录,然后才能查看帖子 似乎没有存储 cookie 我发现了以下 cookie。在我的页面的 Firefox 中:

Cookie 名称:remember_user_token 过期:会话结束时

这是应该存储并在未来日期过期的 cookie,但在会话结束时过期吗?有人可以验证这一点吗?

我尝试过对 devise.rb 中的 config.remember_for = 2.weeks 进行注释和取消注释到不同的设置,但似乎没有任何方法可以解决问题。

我的 User.rb 文件如下所示:

用户类< ActiveRecord::Base

设计:database_authenticatable,:可注册, :可恢复,:可记住,:可跟踪,:可验证

# 设置模型的可访问(或受保护)属性

attr_accessible :电子邮件、:密码、:password_confirmation、:remember_me

结束

I've set up a simple sample app that uses devise for user authentication.

When I select the rember me checkbox on login I get the following in the console:

Processing by Devise::SessionsController#create as HTML
Parameters: {"commit"=>"Sign in", "authenticity_token"=>"Vm+2aWEmCRnnjdXAOpXdI5dGChUKlEcmfGNXNoGUkwc=", "utf8"=>"Γ£ô", "user"=>{"remember_me"=>"1", "password"
=>"[FILTERED]", "email"=>"[email protected]"}}
←[1m←[35mUser Load (1.0ms)←[0m SELECT "users".* FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1
←[1m←[36mAREL (1.0ms)←[0m ←[1mUPDATE "users" SET "last_sign_in_at" = '2011-10-06 21:36:46.439511', "updated_at" = '2011-10-06 21:43:59.298269', "sign_in_coun
t" = 15, "current_sign_in_at" = '2011-10-06 21:43:59.297269' WHERE "users"."id" = 1←[0m

I have the following in my Posts controller:

before_filter :authenticate_user!

However, when I close the browser and open it again I am forced to login again before I can view posts. It doesn't seem that the cookie is being stored. I found the following cookie in firefox for my page:

Cookie Name: remember_user_token
Expires: at end of session

Is this the cookie thats supposed to be stored and expire at a future date but instead expires at the end of session? Can someone verify this?

I've tried both commenting and uncommenting config.remember_for = 2.weeks in devise.rb to different settings and nothing seems to fix the problem.

My User.rb file looks like this:

class User < ActiveRecord::Base

devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable

# Setup accessible (or protected) attributes for your model

attr_accessible :email, :password, :password_confirmation, :remember_me

end

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文