Menu

Migrating legacy $_SESSION authentication to Symfony
📰

Migrating legacy $_SESSION authentication to Symfony

DEV Community: php·Carlos Gude Sánchez·about 7 hours ago
#hHgTT5oW
#devto#dev#user#request#symfony
Reading 0:00
15s threshold

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.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.