【问题标题】:UserWarning: The 'session' cookie is too large: the value was 14773751 bytes but the header required 26 extra bytes用户警告:“会话”cookie 太大:值为 14773751 字节,但标头需要 26 个额外字节
【发布时间】:2022-01-29 17:08:01
【问题描述】:

我需要在烧瓶会话中存储数据帧,我这样做:

session['pd'] = pd.to_dict()

我有这个错误:

UserWarning: The 'session' cookie is too large: the value was 14773751 bytes but the header required 26 extra bytes. The final size was 14773777 bytes but the limit is 4093 bytes. Browsers may silently ignore cookies larger than this.
samesite=samesite,

我添加了这一行:

app.config["SESSION_TYPE"] = "filesystem"

但没有任何改变!

我该如何解决这个问题?

【问题讨论】:

标签: python html dataframe flask flask-session


【解决方案1】:

您是否尝试过使用session.clear() 重置会话?这个,结合app.config["SESSION_TYPE"] = "filesystem" 应该可以完成这项工作。

但是,将 Pandas 数据帧存储到 Flask 会话中根本不可行。我建议你看看Flask Session,这是一个增加对服务器端会话支持的扩展。如果您的要求允许,这可能是可行的方法。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-17
    • 2017-08-29
    • 2016-05-30
    • 2018-05-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多