psr7-cookies
psr7-cookies copied to clipboard
Improve API
Currently it's kind of a PITA to set custom properties for cookies...
e.g. you want to set a normal cookie with SameSite specified (or maybe combined with a expires in)
Goals:
- You can set individual parameters (with immutable API)
- There are multiple ways to define time component: expires at, expires in, seconds valid, ... (This also needs to be testable, so a clock as dependency would be nice)
- You cannot create an invalid cookie
- It just works!
- The current methods are preserved for backwards compat
That's not an issue in PHP 8 anymore.
$cookie = new SetCookie('foo', 'bar', httpOnly: true);