PHP cookie name cannot be used. PHP cookie _ PHP Tutorial

Source: Internet
Author: User
The vertex number that cannot be used by the phpcookie name. The phpcookie is used. Phpcookie names cannot be used. The title of phpcookie is not very strict. it should be said that the cookie name can be used but will be converted. you name a cookie: $ _ COOKIE [the DOT number that cannot be used by the'm php cookie name, which is used by phpcookie

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

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

In fact, you cannot find this value in the cookie through 'My. name'. it can only be 'My _ name ':

echo $_COOKIE[‘my_name'];

Php has automatically converted to underline.

Why does php do this? This is because $ _ GET/$ _ POST/$ _ SERVER/$ _ COOKIE... In many previous versions, the values of these global functions can be directly accessed locally using the register_globals parameter. for example, after register_globals = on is enabled, the value of $ my_name for access is 1. If it is $ my. name, it does not comply with the naming principles of php variables. this is not just a problem of periods.

Therefore, the $ _ COOKIE name complies with the php naming standard.

In addition, enabling register_globals is a bad decision, because it may overwrite the original value in the script, for example:

// other codeif ($a)    $uc_is_login = true;// ...

The user only needs to send a url? A = 1 http request can be logged in by default. This is a very dangerous practice and should be disabled. In fact, php6 has removed this option.

Php cannot save cookies. The value is too small.

When a web page is submitted, it will contain a cookie. Therefore, the cookie is usually not very large, otherwise the web page will be slow.
This is why images and other resources are different from the domain names of the main site.
The idea above is not the same as that of session. Session is the unique PHPSESSID (in cookie) of each user's session ).
Give you an http request image.




Use of cookies in php

Date_default_timezone_set ("PRC ");
Setcookie ("name", "Xiaoluo", time () + 3600 );
Echo "your name is:". $ _ COOKIE ["name"];
?>

Http://www.bkjia.com/PHPjc/896044.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/896044.htmlTechArticlephp cookie name cannot use the dot, phpcookie use this title is not very strict, it should be said that can use the dot 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.