1--TEST-- 2setrawcookie() error tests 3--INI-- 4date.timezone=UTC 5--FILE-- 6<?php 7 8ob_start(); 9 10try { 11 setrawcookie(''); 12} catch (\ValueError $e) { 13 echo $e->getMessage() . "\n"; 14} 15try { 16 setrawcookie('invalid='); 17} catch (\ValueError $e) { 18 echo $e->getMessage() . "\n"; 19} 20try { 21 setrawcookie('name', 'invalid;'); 22} catch (\ValueError $e) { 23 echo $e->getMessage() . "\n"; 24} 25try { 26 setrawcookie('name', 'value', 100, 'invalid;'); 27} catch (\ValueError $e) { 28 echo $e->getMessage() . "\n"; 29} 30try { 31 setrawcookie('name', 'value', 100, 'path', 'invalid;'); 32} catch (\ValueError $e) { 33 echo $e->getMessage() . "\n"; 34} 35 36if (PHP_INT_SIZE == 8) { 37 try { 38 // To go above year 9999: 60 * 60 * 24 * 365 * 9999 39 setrawcookie('name', 'value', 315328464000); 40 } catch (\ValueError $e) { 41 var_dump($e->getMessage() == 'setrawcookie(): "expires" option cannot have a year greater than 9999'); 42 } 43} else { 44 var_dump(true); 45} 46 47var_dump(headers_list()); 48 49?> 50--EXPECTHEADERS-- 51 52--EXPECTF-- 53setrawcookie(): Argument #1 ($name) cannot be empty 54setrawcookie(): Argument #1 ($name) cannot contain "=", ",", ";", " ", "\t", "\r", "\n", "\013", or "\014" 55setrawcookie(): Argument #2 ($value) cannot contain ",", ";", " ", "\t", "\r", "\n", "\013", or "\014" 56setrawcookie(): "path" option cannot contain ",", ";", " ", "\t", "\r", "\n", "\013", or "\014" 57setrawcookie(): "domain" option cannot contain ",", ";", " ", "\t", "\r", "\n", "\013", or "\014" 58bool(true) 59array(1) { 60 [0]=> 61 string(%d) "X-Powered-By: PHP/%s" 62} 63