使用下面的应用程序和Flask 0.11.1,我导航到与以下函数调用关联的路由,给定结果:
> create():’1,2,3’#OK
>删除(1):’2,3’#OK
>删除(2):’1,3’#expected’3′
> maintain():’1,3’#expected’1,3’或’3′
from flask import Flask,session app = Flask(__name__) @app.route('/') def create(): session['list'] = ['1','2','3'] return ",".join(session['list']) @app.route('/m') def maintain(): return ",".join(session['list']) @app.route('/r/<int:id>') def remove(id): session['list'].remove(str(id)) return ",".join(session['list']) if __name__ == '__main__': app.secret_key = "123" app.run()
这个问题在主题上类似于this question,this和this one,但是我设置了密钥而没有重新生成它,我的变量肯定不大于cookie允许的4096字节.也许我错过了一些关于Flask会话变量的基本理解?