@@ -213,32 +213,28 @@ static int php_head_parse_cookie_options_array(zval *options, zend_long *expires
213
213
214
214
if (* path ) {
215
215
* path = NULL ;
216
- * domain = NULL ;
217
- * secure = 0 ;
218
- * httponly = 0 ;
219
216
php_error_docref (NULL , E_WARNING , "Cannot pass arguments after the options array" );
220
217
return 0 ;
221
218
}
222
219
223
220
ZEND_HASH_FOREACH_STR_KEY_VAL (Z_ARRVAL_P (options ), key , value ) {
224
221
if (key ) {
225
- ZVAL_DEREF (value );
226
- if (!strcasecmp ("expires" , ZSTR_VAL (key ))) {
222
+ if (zend_string_equals_literal_ci (key , "expires" )) {
227
223
* expires = zval_get_long (value );
228
224
found ++ ;
229
- } else if (! strcasecmp ( "path" , ZSTR_VAL ( key ) )) {
225
+ } else if ( zend_string_equals_literal_ci ( key , "path" )) {
230
226
* path = zval_get_string (value );
231
227
found ++ ;
232
- } else if (! strcasecmp ( "domain" , ZSTR_VAL ( key ) )) {
228
+ } else if ( zend_string_equals_literal_ci ( key , "domain" )) {
233
229
* domain = zval_get_string (value );
234
230
found ++ ;
235
- } else if (! strcasecmp ( "secure" , ZSTR_VAL ( key ) )) {
231
+ } else if ( zend_string_equals_literal_ci ( key , "secure" )) {
236
232
* secure = zval_is_true (value );
237
233
found ++ ;
238
- } else if (! strcasecmp ( "httponly" , ZSTR_VAL ( key ) )) {
234
+ } else if ( zend_string_equals_literal_ci ( key , "httponly" )) {
239
235
* httponly = zval_is_true (value );
240
236
found ++ ;
241
- } else if (! strcasecmp ( "samesite" , ZSTR_VAL ( key ) )) {
237
+ } else if ( zend_string_equals_literal_ci ( key , "samesite" )) {
242
238
* samesite = zval_get_string (value );
243
239
found ++ ;
244
240
} else {
@@ -265,7 +261,7 @@ PHP_FUNCTION(setcookie)
265
261
zval * expires_or_options = NULL ;
266
262
zend_string * name , * value = NULL , * path = NULL , * domain = NULL , * samesite = NULL ;
267
263
zend_long expires = 0 ;
268
- zend_bool secure = 0 , httponly = 0 , options_array = 0 ;
264
+ zend_bool secure = 0 , httponly = 0 ;
269
265
270
266
ZEND_PARSE_PARAMETERS_START (1 , 7 )
271
267
Z_PARAM_STR (name )
@@ -280,7 +276,6 @@ PHP_FUNCTION(setcookie)
280
276
281
277
if (expires_or_options ) {
282
278
if (Z_TYPE_P (expires_or_options ) == IS_ARRAY ) {
283
- options_array = 1 ;
284
279
if (!php_head_parse_cookie_options_array (expires_or_options , & expires , & path , & domain , & secure , & httponly , & samesite )) {
285
280
RETVAL_FALSE ;
286
281
goto cleanup ;
@@ -297,7 +292,7 @@ PHP_FUNCTION(setcookie)
297
292
}
298
293
299
294
cleanup :
300
- if (options_array ) {
295
+ if (expires_or_options && Z_TYPE_P ( expires_or_options ) == IS_ARRAY ) {
301
296
if (path ) {
302
297
zend_string_release (path );
303
298
}
0 commit comments