Toward A Better Separation of Session Behaviors in PHP
Andrew Shell asks, What is the best way to handle sessions with ADR? (The problem is that the built-in PHP session extension combines the concerns of reading input, managing storage, and sending output; the solution is a domain-layer session-data manager.)
Iâve reached a point with a couple of my Radar projects where I need to add a login and set permissions. Iâm trying to figure out the best way to handle this, especially with PSR-7 and ADR. ...
[In Action-Domain-Responder] itâs ok to read the session cookie in an Input class, and itâs ok to write the cookie in a Responder class, but pretty much everything else should be in the Domain layer. ...
[In the Domain layer,] Cadre.DomainSession takes a session id (or generates one) and loads session data from storage. Itâs smart enough to handle regenerating session ids and cleaning up expired sessions.
Read the whole article at FutureProof PHP for examples and links!
UPDATE: Reddit discussion.