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
16echo "*** Testing session_regenerate_id() : basic functionality for cookie ***\n";
17
18require __DIR__.'/../../../sapi/cgi/tests/include.inc';
19
20$php = get_cgi_path();
21reset_env_vars();
22
23$file = __DIR__."/session_regenerate_id_cookie.test.php";
24
25file_put_contents($file, '<?php
26ob_start();
27
28function find_cookie_header() {
29    $headers = headers_list();
30    $target  = "Set-Cookie: PHPSESSID=";
31    foreach ($headers as $h) {
32        if (strstr($h, $target) !== FALSE) {
33            echo $h."\n";
34            return TRUE;
35        }
36    }
37    var_dump($headers);
38    return FALSE;
39}
40
41var_dump(session_start());
42var_dump(find_cookie_header());
43$id = session_id();
44var_dump(session_regenerate_id());
45var_dump(find_cookie_header());
46var_dump($id !== session_id());
47var_dump(session_id());
48var_dump(session_destroy());
49
50ob_end_flush();
51?>');
52
53var_dump(`$php -n -d session.name=PHPSESSID $file`);
54
55unlink($file);
56
57echo "Done";
58?>
59--EXPECTF--
60*** Testing session_regenerate_id() : basic functionality for cookie ***
61string(%d) "X-Powered-By: PHP/%d.%d.%s
62Expires: %s
63Cache-Control: no-store, no-cache, must-revalidate
64Pragma: no-cache
65Set-Cookie: PHPSESSID=%s; path=/
66Content-type: text/html; charset=UTF-8
67
68bool(true)
69Set-Cookie: PHPSESSID=%s; path=/
70bool(true)
71bool(true)
72Set-Cookie: PHPSESSID=%s; path=/
73bool(true)
74bool(true)
75string(32) "%s"
76bool(true)
77"
78Done
79