@@ -52,7 +52,8 @@ public function __construct(
52
52
protected bool $ secure = false ,
53
53
protected bool $ httpOnly = true ,
54
54
protected bool $ raw = false ,
55
- ?string $ sameSite = null
55
+ ?string $ sameSite = null ,
56
+ protected bool $ partitioned = false
56
57
) {
57
58
// from PHP source code
58
59
if (preg_match ("/[=,; \t\r\n\013\014]/ " , $ name )) {
@@ -130,6 +131,10 @@ public function __toString()
130
131
$ str .= '; samesite= ' . $ this ->getSameSite ();
131
132
}
132
133
134
+ if ($ this ->isPartitioned ()) {
135
+ $ str .= '; partitioned ' ;
136
+ }
137
+
133
138
return $ str ;
134
139
}
135
140
@@ -146,6 +151,7 @@ public static function fromString(string $cookie, bool $decode = false): self
146
151
'httponly ' => false ,
147
152
'raw ' => ! $ decode ,
148
153
'samesite ' => null ,
154
+ 'partitioned ' => false ,
149
155
];
150
156
foreach (explode ('; ' , $ cookie ) as $ part ) {
151
157
if (! str_contains ($ part , '= ' )) {
@@ -183,7 +189,8 @@ public static function fromString(string $cookie, bool $decode = false): self
183
189
$ data ['secure ' ],
184
190
$ data ['httponly ' ],
185
191
$ data ['raw ' ],
186
- $ data ['samesite ' ]
192
+ $ data ['samesite ' ],
193
+ $ data ['partitioned ' ]
187
194
);
188
195
}
189
196
@@ -274,4 +281,12 @@ public function getSameSite(): ?string
274
281
{
275
282
return $ this ->sameSite ;
276
283
}
284
+
285
+ /**
286
+ * Checks whether the cookie should be tied to the top-level site in cross-site context.
287
+ */
288
+ public function isPartitioned (): bool
289
+ {
290
+ return $ this ->partitioned ;
291
+ }
277
292
}
0 commit comments