相关疑难解决方法(0)

会话数据仅在Chrome中丢失

我有一个类似的问题,如果不是这个线程中的问题相同: 只在谷歌Chrome和URL重写中随机丢失会话变量

但是该线程中的所有解决方案对我都不起作用.我在我的PHP/MySQL应用程序中只从Google Chrome中获得了一个奇怪的行为.如果我尝试使用Firefox,它可以运行,但Chrome不会.

我导航到购物车中的某个地方,代码中的几个地方我将存储会话数据.不要担心我开始会议或与此相关的任何事情,我已经在webapp开发工作了11年,一切都很好.

在所有浏览器中,我都可以var_dump($_SESSION)恢复我的数据,但在Chrome中,它不会保留数据.另请注意,会话确实已经传递,我可以查看网络监视器,我看到正在发送的cookie以及与会话工作相关的许多其他事情但是$_SESSION['last_viewed_element']没有保留.我似乎也无法设置任何其他东西,所有人都迷失了.

编辑:

从SESSIONS切换到COOKIES解决了问题...

php session google-chrome

30
推荐指数
3
解决办法
5万
查看次数

重定向后 Flask 会话为空

我有这样的代码:

from flask import Flask, render_template, redirect, request, url_for, session

app = Flask(__name__)


@app.route('/')
def index():
    tmplt = session.get('template', 'No template')
    return render_template('index.html', template=tmplt.decode('utf-8'))


@app.route('/template', methods=['POST'])
def upload_template():
    session['template'] = request.files['template'].read()
    return redirect(url_for('index'))


if __name__ == '__main__':
    app.secret_key = '\x0cw1\xd4\xd5\x80%O?q \xcfQrrk\xa3H\xc0[J\xae<\xc3]\xe6\x10\xc0-\xf8S\x08P4[3]PrK\xa9\xf1'
    app.run(debug=True)
Run Code Online (Sandbox Code Playgroud)

我预计,成功执行后POST /template,变量tmplt将等于上传的内容。然而,它是空的。调试显示session['template']在重定向之前按照预期存储了文件内容。

任何人都可以建议这里有什么问题吗?Flask 文档和谷歌搜索没有帮助:(

python flask

1
推荐指数
1
解决办法
4492
查看次数

标签 统计

flask ×1

google-chrome ×1

php ×1

python ×1

session ×1