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