@@ -79,7 +79,7 @@ PHPAPI bool php_header(void)
7979#define ILLEGAL_COOKIE_CHARACTER "\",\", \";\", \" \", \"\\t\", \"\\r\", \"\\n\", \"\\013\", or \"\\014\""
8080PHPAPI zend_result php_setcookie (zend_string * name , zend_string * value , time_t expires ,
8181 zend_string * path , zend_string * domain , bool secure , bool httponly ,
82- zend_string * samesite , bool url_encode )
82+ zend_string * samesite , bool partitioned , bool url_encode )
8383{
8484 zend_string * dt ;
8585 sapi_header_line ctr = {0 };
@@ -182,6 +182,9 @@ PHPAPI zend_result php_setcookie(zend_string *name, zend_string *value, time_t e
182182 smart_str_appends (& buf , COOKIE_SAMESITE );
183183 smart_str_append (& buf , samesite );
184184 }
185+ if (partitioned ) {
186+ smart_str_appends (& buf , COOKIE_PARTITIONED );
187+ }
185188
186189 ctr .line = ZSTR_VAL (buf .s );
187190 ctr .line_len = (uint32_t ) ZSTR_LEN (buf .s );
@@ -192,7 +195,7 @@ PHPAPI zend_result php_setcookie(zend_string *name, zend_string *value, time_t e
192195}
193196
194197static zend_result php_head_parse_cookie_options_array (HashTable * options , zend_long * expires , zend_string * * path ,
195- zend_string * * domain , bool * secure , bool * httponly , zend_string * * samesite )
198+ zend_string * * domain , bool * secure , bool * httponly , zend_string * * samesite , bool * partitioned )
196199{
197200 zend_string * key ;
198201 zval * value ;
@@ -212,6 +215,8 @@ static zend_result php_head_parse_cookie_options_array(HashTable *options, zend_
212215 * secure = zval_is_true (value );
213216 } else if (zend_string_equals_literal_ci (key , "httponly" )) {
214217 * httponly = zval_is_true (value );
218+ } else if (zend_string_equals_literal_ci (key , "partitioned" )) {
219+ * partitioned = zval_is_true (value );
215220 } else if (zend_string_equals_literal_ci (key , "samesite" )) {
216221 * samesite = zval_get_string (value );
217222 } else {
@@ -227,9 +232,9 @@ static void php_setcookie_common(INTERNAL_FUNCTION_PARAMETERS, bool is_raw)
227232 HashTable * options = NULL ;
228233 zend_long expires = 0 ;
229234 zend_string * name , * value = NULL , * path = NULL , * domain = NULL , * samesite = NULL ;
230- bool secure = 0 , httponly = 0 ;
235+ bool secure = 0 , httponly = 0 , partitioned = 0 ;
231236
232- ZEND_PARSE_PARAMETERS_START (1 , 7 )
237+ ZEND_PARSE_PARAMETERS_START (1 , 8 )
233238 Z_PARAM_STR (name )
234239 Z_PARAM_OPTIONAL
235240 Z_PARAM_STR (value )
@@ -238,6 +243,7 @@ static void php_setcookie_common(INTERNAL_FUNCTION_PARAMETERS, bool is_raw)
238243 Z_PARAM_STR (domain )
239244 Z_PARAM_BOOL (secure )
240245 Z_PARAM_BOOL (httponly )
246+ Z_PARAM_BOOL (partitioned )
241247 ZEND_PARSE_PARAMETERS_END ();
242248
243249 if (options ) {
@@ -248,13 +254,13 @@ static void php_setcookie_common(INTERNAL_FUNCTION_PARAMETERS, bool is_raw)
248254 }
249255
250256 if (FAILURE == php_head_parse_cookie_options_array (options , & expires , & path ,
251- & domain , & secure , & httponly , & samesite )
257+ & domain , & secure , & httponly , & samesite , & partitioned )
252258 ) {
253259 goto cleanup ;
254260 }
255261 }
256262
257- if (php_setcookie (name , value , expires , path , domain , secure , httponly , samesite , !is_raw ) == SUCCESS ) {
263+ if (php_setcookie (name , value , expires , path , domain , secure , httponly , samesite , partitioned , !is_raw ) == SUCCESS ) {
258264 RETVAL_TRUE ;
259265 } else {
260266 RETVAL_FALSE ;
0 commit comments