1--TEST-- 2Test session_set_cookie_params() function : array parameter variation 3--INI-- 4session.cookie_lifetime=0 5session.cookie_path="/" 6session.cookie_domain="" 7session.cookie_secure=0 8session.cookie_httponly=0 9session.cookie_samesite="" 10--EXTENSIONS-- 11session 12--SKIPIF-- 13<?php include('skipif.inc'); ?> 14--FILE-- 15<?php 16 17ob_start(); 18 19echo "*** Testing session_set_cookie_params() : array parameter variation ***\n"; 20 21// Invalid cases 22try { 23 session_set_cookie_params([]); 24} catch (ValueError $exception) { 25 echo $exception->getMessage() . "\n"; 26} 27 28try { 29 session_set_cookie_params(["unknown_key" => true, "secure_invalid" => true]); 30} catch (ValueError $exception) { 31 echo $exception->getMessage() . "\n"; 32} 33 34var_dump(ini_get("session.cookie_secure")); 35var_dump(ini_get("session.cookie_samesite")); 36var_dump(session_set_cookie_params(["secure" => true, "samesite" => "please"])); 37var_dump(ini_get("session.cookie_secure")); 38var_dump(ini_get("session.cookie_samesite")); 39 40var_dump(ini_get("session.cookie_lifetime")); 41var_dump(session_set_cookie_params(["lifetime" => 42])); 42var_dump(ini_get("session.cookie_lifetime")); 43 44var_dump(ini_get("session.cookie_path")); 45 46try { 47 session_set_cookie_params(["path" => "newpath/"], "arg after options array"); 48} catch (ValueError $exception) { 49 echo $exception->getMessage() . "\n"; 50} 51 52var_dump(ini_get("session.cookie_path")); 53 54echo "Done"; 55ob_end_flush(); 56?> 57--EXPECTF-- 58*** Testing session_set_cookie_params() : array parameter variation *** 59session_set_cookie_params(): Argument #1 ($lifetime_or_options) must contain at least 1 valid key 60 61Warning: session_set_cookie_params(): Argument #1 ($lifetime_or_options) contains an unrecognized key "unknown_key" in %s on line %d 62 63Warning: session_set_cookie_params(): Argument #1 ($lifetime_or_options) contains an unrecognized key "secure_invalid" in %s on line %d 64session_set_cookie_params(): Argument #1 ($lifetime_or_options) must contain at least 1 valid key 65string(1) "0" 66string(0) "" 67bool(true) 68string(1) "1" 69string(6) "please" 70string(1) "0" 71bool(true) 72string(2) "42" 73string(1) "/" 74session_set_cookie_params(): Argument #2 ($path) must be null when argument #1 ($lifetime_or_options) is an array 75string(1) "/" 76Done 77