In a legacy PHP application I worked on, user information lived in $_SESSION . Code across the application reached into it whenever it needed an ID, a name or some other part of the user's context.
I moved that authentication into Symfony. The login was part of the job, but so was finding every caller that expected those session entries to exist.
One decision helped throughout the migration: I kept the names of the user fields and the responses that existing callers expected.
The details below have been anonymized. Field names, payloads and code examples have been changed to keep the original application out of the article.
What the old code expected
The middleware started the PHP session and populated it with user information.…