Home >Backend Development >PHP Tutorial >PHP cookie names using dots (periods) will be converted_PHP Tutorial

PHP cookie names using dots (periods) will be converted_PHP Tutorial

WBOY
WBOYOriginal
2016-07-13 10:16:051092browse

PHP cookie names that use dots (periods) will be converted

This title is not very strict. It should be said that you can use dotted cookie names, but they will be converted. You name it A cookie:

 $_COOKIE[‘my.name’] = 1;

Actually you cannot find this value in the cookie through 'my.name', only 'my_name':

echo $_COOKIE[‘my_name’];

PHP has automatically converted it for you, and the period has been converted to an underscore.

Why does php do this? This is because of $_GET/$_POST/$_SERVER/$_COOKIE. . . The values ​​of these global functions can be directly accessed locally through the register_globals parameter in many previous versions. For example, after turning on register_globals = on, accessing $my_name directly takes the value to 1. If it is $my.name, it does not comply with the PHP variable naming principle. This is not just a problem with the period (.).

Therefore, the naming of $_COOKIE already complies with the PHP naming standard.

It is a bad decision to enable register_globals in addition, because it may overwrite the original value in the script, such as:

// other code

 if ($a)

$uc_is_login = true;

 // ...

Users only need to send an http request with url?a=1 to be logged in by default. This is a very dangerous practice and should be shut down. In fact, php6 has removed this option.

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/899488.htmlTechArticlephp cookie name will be converted if you use a period (period). This title is not very strict. It should be said that you can use a period. cookie name, but will be converted as you name a cookie: $_COOKIE[my.name'] =...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn