Radar Domain Session Demo
git clone https://github.com/futureproofphp/radar-domain-session.git cd radar-domain-session # Install dependencies composer install
This demo is very simple and mirrors the functionality of the non-radar demo included in Cadre.DomainSession.
To simplify getting and setting cookies in PSR-7 I'm using the excellent dflydev-fig-cookies library.
Input we fetch the session id cookie value. It is null if none exists.
It loads the session (creates a new one if none exists) and checks to see if there is a timestamp value present. If none it returns "Unknown" and assigns the current timestamp to the session.
The session is finished and persisted.
Responder we check to see if there was a session returned from the domain.
If so, we check to see if the session id was updated (new or regenerated session id).
If it was we assign the session id to the session cookie.