【发布时间】:2017-06-17 06:05:23
【问题描述】:
我有一个 VueJS 应用程序,它使用构建在 Flask 网络服务器上的 vue-resource。我正在尝试使用烧瓶会话来存储非敏感数据。
请求.vue:
this.$http.post('/additem', postData)
.then(function success(res) {
console.log('all items after add:', res.body);
});
routes.py:
APP.config.update(
SESSION_COOKIE_HTTPONLY=False,
SECRET_KEY='speakfriend'
)
@APP.route('/', methods=['GET'])
def index():
return render_template('index.html', rawsettings=config)
@APP.route('/additem', methods=['POST'])
def add_item():
entity_id = request.form.get('entity_id')
session['items'].append(entity_id)
print('items: {}'.format(session['items']))
session.modified = True
return jsonify(session['items'])
每次我点击/additem 路由时,响应的 Set-Cookie 标头与请求标头中发送的会话密钥不同。我错过了什么?
【问题讨论】:
标签: session flask vue.js vue-resource