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--SKIPIF--
11<?php include('skipif.inc'); ?>
12--FILE--
13<?php
14
15ob_start();
16
17/*
18 * Prototype : void session_set_cookie_params(array $options)
19 * Description : Set the session cookie parameters
20 * Source code : ext/session/session.c
21 */
22
23echo "*** Testing session_set_cookie_params() : array parameter variation ***\n";
24
25// Invalid cases
26var_dump(session_set_cookie_params([]));
27var_dump(session_set_cookie_params(["unknown_key" => true, "secure_invalid" => true]));
28
29var_dump(ini_get("session.cookie_secure"));
30var_dump(ini_get("session.cookie_samesite"));
31var_dump(session_set_cookie_params(["secure" => true, "samesite" => "please"]));
32var_dump(ini_get("session.cookie_secure"));
33var_dump(ini_get("session.cookie_samesite"));
34
35var_dump(ini_get("session.cookie_lifetime"));
36var_dump(session_set_cookie_params(["lifetime" => 42]));
37var_dump(ini_get("session.cookie_lifetime"));
38
39var_dump(ini_get("session.cookie_path"));
40var_dump(session_set_cookie_params(["path" => "newpath/"], "arg after options array"));
41var_dump(ini_get("session.cookie_path"));
42
43echo "Done";
44ob_end_flush();
45?>
46--EXPECTF--
47*** Testing session_set_cookie_params() : array parameter variation ***
48
49Warning: session_set_cookie_params(): No valid keys were found in the options array in %s
50bool(false)
51
52Warning: session_set_cookie_params(): Unrecognized key 'unknown_key' found in the options array in %s
53
54Warning: session_set_cookie_params(): Unrecognized key 'secure_invalid' found in the options array in %s
55
56Warning: session_set_cookie_params(): No valid keys were found in the options array in %s
57bool(false)
58string(1) "0"
59string(0) ""
60bool(true)
61string(1) "1"
62string(6) "please"
63string(1) "0"
64bool(true)
65string(2) "42"
66string(1) "/"
67
68Warning: session_set_cookie_params(): Cannot pass arguments after the options array in %s
69bool(false)
70string(1) "/"
71Done
72