【问题标题】:How to fix 「ActionDispatch::Cookies::CookieOverflow」 when using devise使用设计时如何修复「ActionDispatch::Cookies::CookieOverflow」
【发布时间】:2022-01-16 21:13:29
【问题描述】:

想要实现

Ruby 2.6.5
Ruby on Rails 6.0.3

感谢您的光临!
我正在用 Ruby on Rails 创建一个应用程序。
我也在使用 devise 来建立登录关系。

突然出现以下错误:

ActionDispatch::Cookies::CookieOverflow (ActionDispatch::Cookies::CookieOverflow) 

错误信息说cookie太多,所以我查看了session的内容。

session.to_hash
=> {"session_id"=>"4ceff7435d264fb8f7b41bacb8f2ba06",
 "_csrf_token"=>"zrbECxocvrrdIRD85hABDE18kRwiIttAP2B3hvbkeuk=",
 "warden.user.user.key"=>
  #<User id: 160, email: "sbxtestmike+latest3@gmail.com", last_name: "test_lastname", first_name: "test_firstname", profile: "In the event that you're looking for the best way to get the most out of your business, you'll be able to get the most..."}

似乎当用户配置文件中有大量数据时会发生此错误。所以我想避免只在会话中存储配置文件。

我不知道在哪里解决这个问题。
如果你能给我一些提示或想法,我很乐意听到。

这是我认为相关的代码。

    def verify
      prms = verify_params

        logger.debug 'success'
        sign_in(:user, @user)

        @resource = @user
        @resource.tokens = nil
        @token = @resource.create_token
        @resource.save!

        auth_header = @resource.build_auth_header(@token.token, @token.client)
        response.headers.merge!(auth_header)

      end
    end

【问题讨论】:

    标签: ruby-on-rails cookies devise


    【解决方案1】:

    首先在哪个目录中有太多cookie?

    为什么不先检查 cookie,然后再检查 CRUD。

    考虑哈希和符号的组合,使您的数据更简洁但仍然实用。

    【讨论】:

    • 正如目前所写,您的答案尚不清楚。请edit 添加其他详细信息,以帮助其他人了解这如何解决所提出的问题。你可以找到更多关于如何写好答案的信息in the help center
    猜你喜欢
    • 2015-02-21
    • 1970-01-01
    • 2015-03-01
    • 1970-01-01
    • 2011-06-14
    • 1970-01-01
    • 2019-03-04
    • 2019-11-16
    • 1970-01-01
    相关资源
    最近更新 更多