PHP cookie name cannot use the dot number, Phpcookie use _php tutorial

Source: Internet
Author: User

PHP cookie name can not use the dot number, Phpcookie use


This title is not very strict, it should be said that you can use the dot number of the cookie name, but will be converted, you name a cookie:

$_cookie['my.name '] = 1;

In fact, you cannot find this value in a cookie by ' my.name ', Only ' my_name ':

Echo $_cookie['my_name '];

PHP has automatically converted you, and the period turns to underline.

Why does PHP want to do this? This is because $_get/$_post/$_server/$_cookie ... The values of these global functions, in many previous versions, can be accessed directly locally by the Register_globals parameter, for example, when register_globals = On is on, access to the $my_name directly takes a value of 1. If it is $my.name, then it does not conform to the PHP variable naming principle, which is not just a period (.) problem.

As a result, $_cookie's name already conforms to the PHP naming standard.

Also, turning on register_globals is a bad decision because it might overwrite the original values in the script, such as:

// Other code if ($a)     $uc _is_login true ; //  ...

The user simply sends a url?a=1 HTTP request to be logged on by default. This is a very dangerous practice and it should be shut down. In fact, PHP6 has removed this option.

PHP can not save cookies, the value is too small

Web pages will bring cookies when they are submitted, so cookies are generally not very large, otherwise the pages will be slow.
This is why the image and other resources with the main station is not the same domain name.
The idea upstairs is not the same as the session. The session is the user's only PHPSESSID (in a cookie) for each user's session.
Give you a picture of an HTTP request.




Use of cookies in PHP

Date_default_timezone_set ("PRC");
Setcookie ("name", "Little Luo", Time () +3600);
echo "Your name is:". $_cookie["name"];
?>

http://www.bkjia.com/PHPjc/896044.html www.bkjia.com true http://www.bkjia.com/PHPjc/896044.html techarticle PHP cookie name can not use the dot number, Phpcookie use this title is not very strict, should say can use the dot number of the cookie name, but will be converted, you name a cookie: $_cookie[' m ...

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.