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