Re: [RFC] Add SameSite cookie attribute parameter

From: Date: Wed, 18 Jan 2023 15:20:18 +0000
Subject: Re: [RFC] Add SameSite cookie attribute parameter
References: 1 2 3 4 5 6  Groups: php.internals 
Request: Send a blank email to internals+get-119311@lists.php.net to get a copy of this message
On Tue, 17 Jan 2023, Christian Schneider wrote: > Am 17.01.2023 um 15:59 schrieb G. P. B. <george.banyard@gmail.com>: > > > > I might be again misunderstanding, but one cannot extend an enum as > > they are final classes under the hood. Currently, the only other > > native enum is the one that was added with the Randomizer Additions > > RFC [1] so this topic hasn't come up yet as the enum for ext-random > > is definetely complete. > > I'm talking about adding new values in later PHP versions, let's for > example assume they would add a SameSite mode "Stricter" and PHP wants > to support that. How would one write code to use "Stricter" in code > meant to work for both old and new PHP versions? if (version_compare(phpversion(), "8.4.0", ">")) { setcookie("test", "value", samesite: SameSite::Stricter); } else { setcookie("test", "value", samesite: SameSite::Strict); } These are run time checks, not compile time: 8 > JMPZ $1, ->18 ... 13 FETCH_CLASS_CONSTANT ~2 'SameSite', 'Stricter' ... 17 > JMP ->26 18 > EXT_STMT ... 22 FETCH_CLASS_CONSTANT ~4 'SameSite', 'Strict' cheers, Derick

« previous php.internals (#119311) next »