1--TEST--
2Test session_regenerate_id() function : basic functionality
3--SKIPIF--
4<?php
5
6include('skipif.inc');
7
8require __DIR__.'/../../../sapi/cgi/tests/include.inc';
9
10get_cgi_path() or die('skip no cgi');
11
12?>
13--FILE--
14<?php
15
16/*
17 * Prototype : bool session_regenerate_id([bool $delete_old_session])
18 * Description : Update the current session id with a newly generated one
19 * Source code : ext/session/session.c
20 */
21
22echo "*** Testing session_regenerate_id() : basic functionality for cookie ***\n";
23
24require __DIR__.'/../../../sapi/cgi/tests/include.inc';
25
26$php = get_cgi_path();
27reset_env_vars();
28
29$file = dirname(__FILE__)."/session_regenerate_id_cookie.test.php";
30
31file_put_contents($file, '<?php
32ob_start();
33
34function find_cookie_header() {
35	$headers = headers_list();
36	$target  = "Set-Cookie: PHPSESSID=";
37	foreach ($headers as $h) {
38		if (strstr($h, $target) !== FALSE) {
39			echo $h."\n";
40			return TRUE;
41		}
42	}
43	var_dump($headers);
44	return FALSE;
45}
46
47var_dump(session_start());
48var_dump(find_cookie_header());
49$id = session_id();
50var_dump(session_regenerate_id());
51var_dump(find_cookie_header());
52var_dump($id !== session_id());
53var_dump(session_id());
54var_dump(session_destroy());
55
56ob_end_flush();
57?>');
58
59var_dump(`$php -n -d session.name=PHPSESSID $file`);
60
61unlink($file);
62
63echo "Done";
64?>
65--EXPECTF--
66*** Testing session_regenerate_id() : basic functionality for cookie ***
67string(%d) "X-Powered-By: PHP/7.%s
68Expires: %s
69Cache-Control: no-store, no-cache, must-revalidate
70Pragma: no-cache
71Set-Cookie: PHPSESSID=%s; path=/
72Content-type: text/html; charset=UTF-8
73
74bool(true)
75Set-Cookie: PHPSESSID=%s; path=/
76bool(true)
77bool(true)
78Set-Cookie: PHPSESSID=%s; path=/
79bool(true)
80bool(true)
81string(32) "%s"
82bool(true)
83"
84Done
85