note 128065 added to reserved.variables.cookies

From: Date: Thu, 29 Dec 2022 19:04:44 +0000
Subject: note 128065 added to reserved.variables.cookies
Groups: php.notes 
Request: Send a blank email to php-notes+get-220020@lists.php.net to get a copy of this message
The values of $_COOKIE in general are not identic with the values in $_SERVER["HTTP_COOKIE"]! In phpinfo() $_SERVER["HTTP_COOKIE"] shows the actual value stored in the cookie by the browser in 7bit. In $_COOKIE is this value after a 7bit to 8bit conversion. When all characters in $_SERVER["HTTP_COOKIE"] are in ASCII = 7bit, $_COOKIE is displayed in phpinfo(). When one single character is not in ASCII, phpinfo() shows no value! Although in $_COOKIE is still the 8bit conversion of $_SERVER["HTTP_COOKIE"]! The reason: the 8bit conversion alone is not enough to say what characters are meant. For that the used character-set is necessary. phpinfo() does not know the character-set and better says nothing. When using $_COOKIE in a php-generated web page the environment has the info of used character-set and so the meant characters can be displayed. Three illustrating examples =========================== A HTML-form is used to get the content which shall be stored in a cookie named "test". Input string in field "test": door $_SERVER["HTTP_COOKIE"]: test=door $_COOKIE["test"] displayed in phpinfo(): door displayed in any html page: door Input string in field "test" (ISO-8859-1 used in form): Tür $_SERVER["HTTP_COOKIE"]: test=T%FCr $_COOKIE["test"] displayed in phpinfo(): "" displayed in a ISO-8859-1-html-page: Tür (displayed in a UTF-8-html-page: T�r) Input string in field "test" (UTF-8 used in form): Tür $_SERVER["HTTP_COOKIE"]: test=T%C3%BCr $_COOKIE["test"] displayed in phpinfo(): "" displayed in a UTF-8-html-page: Tür (displayed in a ISO-8859-1-html-page: Tür) ---- Server IP: 45.112.84.4 Probable Submitter: 45.91.158.213 (proxied: 109.250.23.197) ---- Manual Page -- https://php.net/manual/en/reserved.variables.cookies.php Edit -- https://main.php.net/note/edit/128065 Del: integrated -- https://main.php.net/note/delete/128065/integrated Del: useless -- https://main.php.net/note/delete/128065/useless Del: bad code -- https://main.php.net/note/delete/128065/bad+code Del: spam -- https://main.php.net/note/delete/128065/spam Del: non-english -- https://main.php.net/note/delete/128065/non-english Del: in docs -- https://main.php.net/note/delete/128065/in+docs Del: other reasons-- https://main.php.net/note/delete/128065 Reject -- https://main.php.net/note/reject/128065 Search -- https://main.php.net/manage/user-notes.php

« previous php.notes (#220020) next »