【问题标题】:Devise for Twitter, Cookie Overflow error?为 Twitter 设计,Cookie 溢出错误?
【发布时间】:2011-10-30 08:08:48
【问题描述】:

我正在尝试使用 guide 将 Twitter 集成到设计中。我基本上把所有出现的 facebook 都用 twitter 代替。但是,当我使用 twitter 登录时,我收到以下错误:

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

在以下网址:

http://localhost:3000/users/auth/twitter/callback?oauth_token=something&oauth_verifier=blah

有什么好的方法可以解决这个问题吗?

谢谢!

【问题讨论】:

    标签: ruby-on-rails twitter devise


    【解决方案1】:

    问题在于session["devise.facebook_data"] = env["omniauth.auth"]。 Twitter 的响应包含一个非常大且不适合会话的extra 部分。一种选择是将env["omniauth.auth"].except("extra") 存储在会话中。

    【讨论】:

    • 为了弄清楚我不需要“额外”部分,我使用了raise request.env["omniauth.auth"].to_yaml
    【解决方案2】:

    您可以为会话打开 ActiveRecord 存储。 查看 config/initializers/session_store.rb

    注释掉关于使用 :cookie_store 的行

    取消注释底部关于使用 :active_record_store 的行

    # Use the database for sessions instead of the cookie-based default,
    # which shouldn't be used to store highly confidential information
    # (create the session table with "rails generate session_migration")
    MyApp::Application.config.session_store :active_record_store
    

    在 rails rails g session_migration 之前创建迁移并迁移它。

    【讨论】:

    • 是否有任何不利的副作用?
    • 我认为只有在会话数据大于 4K 时才应该使用活动记录存储,这比将其存储在 cookie 中要慢一些。
    • 一些开箱即用的开源 cms 无法使用此更改,顺便说一句...
    猜你喜欢
    • 2014-05-26
    • 2021-06-23
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多