Symfony 3 - How to keep session id after logging in?

久未见 提交于 2021-02-20 00:24:47

问题


I want to use the session ID to identify the records in the database for anonymous user. When the user logs in, I would like to bind/relate the data to the user id. However, after logging in the session id is automatically changed by what I lose data binding with the user.

How can I keep the session id after logging in order to bind the user id to the data, and then change the session id?


回答1:


Upon authentication, session should be migrated, unless configured otherwise. Indeed, the session ID is not retained but the data should be there.

Have you checked the security.xml:

session_fixation_strategy:  migrate

This above should be the default (reference). What is the case with your config?

Hope this helps a bit...



来源:https://stackoverflow.com/questions/40624358/symfony-3-how-to-keep-session-id-after-logging-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!