Ajax 正在丢失会话 [英] Ajax is losing sessions

查看:32
本文介绍了Ajax 正在丢失会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将我的 Symfony 应用程序从 Symfony 4.0.7 升级到 Symfony 4.1,之后 AJAX 调用丢失了会话值.

I upgraded my Symfony application from Symfony 4.0.7 to Symfony 4.1 and after that AJAX calls are losing sessions values.

我同时调用了大约 6 个 ajax 请求.第一个进展顺利,但其他人正在失去会话值.它仅在迁移到 Symfony 4.1 之后发生,并且仅适用于 AJAX 调用.有什么想法吗?

I have about 6 ajax requests called at the same time. First of them is going fine but others are losing session values. It happened only after migration to Symfony 4.1 and only for AJAX calls. Any ideas?

它仅在同时调用 ajax 时发生.当我在调用 ajax 之间添加例如 100 毫秒的延迟时,一切正常.

edit: It happens only with ajax called at the same time. WHen I add eg 100 miliseconds delay between calling ajax then all works fine.

edit2:它发生在 4 个不同的服务器上.2 台开发服务器、1 台测试服务器和 1 台实时服务器.它们都运行在 NGINX 和 php7 上

edit2: it happens on 4 different servers. 2 dev servers, 1 test server and 1 live server. all of them run on NGINX and php7

推荐答案

好的,所以问题是因为会话固定策略导致每个请求更改会话 ID,而 AJAX 请求每个请求都没有时间更新新 ID.

Ok, so the problem was because of session fixation strategy which was changing session ID each request and AJAX requests each after another did have time to update the new ID.

一个解决方案非常简单,只需设置session_fixation_strategy: none.

A solution was quite simple, just setting session_fixation_strategy: none.

这篇关于Ajax 正在丢失会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆