Domain Name and cookie problems (domain name suffix)

Source: Internet
Author: User
Tags set cookie in domain

Domain Name and cookie
By accident, I think that can set the cookie to Can set the cookie to

Test results: No. Because the browser knows that the suffix of is rather than. cn, it is prohibited to set cookies.
Because the browser has a built-in domain name suffix list. Todo: if a new suffix appears in the future, but the old browser cannot update the list, wouldn't it allow cookie settings?

Extension suffix Primary Domain Name Second-level domain name . Cn * * *

Can read the cookie?
Can read cookies?
No. Todo: Use and as SSO to prevent the cookie from being sent to
Can read the cookie of
A: No.
Setcookie ('A', 'A', time () + 1234, '/', 'example. com '); is the cookie set to or
A: It is
If you want to set cookies, you need to use setcookie ('default', 'default', time () + 1234 ,'/');.
Cookie setting and reading range:

HTTP request Domain Name Primary Domain Name Cookie configurable (and readable) Range Cookie cannot be set The cookie cannot be read.,,,,,

Set cookie code:
Copy codeThe Code is as follows:
<? Php
Setcookie ('default', 'default', time () + 1234 ,'/');
Setcookie ('A', 'A', time () + 1234, '/', 'example. com ');
Setcookie ('B', 'bb ', time () + 1234,'/',' ');

Read cookie code:
Copy codeThe Code is as follows:
<? Php
Var_dump ($ _ COOKIE );


Related Article

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: 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.