PHP Cookie CN domain Specification

Source: Internet
Author: User
Tags top level domains
I didn't really care about the scope of the cookie before, probably used. com domain name has not been a problem, today with a company's CN domain name test, how can not realize cookie sharing, and later use JS set cookies, in another server sharing cookie success, really called irritating! Flipping through the PHP cookie spec, there's a section

Only hosts within the specified domain can set a cookies for a domain and domains must have at least two (2) or three (3) p Eriods in them to prevent domains of the form: ". com", ". edu", and "va.us". Any domain this fails within one of the seven special top level domains listed below only require two. Any of the other domain requires at least three. The seven special top level domains are: "COM", "EDU", "NET", "ORG", "GOV", "MIL", and "INT".

Look out, you bastard! In addition to "COM", "EDU", "NET", "ORG", "GOV", "MIL", and "INT" These suffixes of the domain name can be set two scope, the other domain name at least three levels can be, That is to say, you want to implement cookie sharing under a.b.cn and c.b.cn by setting the scope for b.cn. PHP can only implement scope b.a.cn under the d.b.a.cn and e.b.a.cn cookie sharing, I hope you notice that again encounter such problems, do not waste time desperately testing ...

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.