psr7-cookies icon indicating copy to clipboard operation
psr7-cookies copied to clipboard

Improve API

Open hansott opened this issue 3 years ago • 1 comments

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

hansott avatar Nov 12 '20 23:11 hansott

That's not an issue in PHP 8 anymore.

$cookie = new SetCookie('foo', 'bar', httpOnly: true);

Chi-teck avatar Jan 19 '21 17:01 Chi-teck