Home >Backend Development >PHP Tutorial >Domain name and cookie issues (domain name suffix)_PHP tutorial
Domain name and cookie
I accidentally thought of a question: www.g.cn can set the cookie to .g.cn, so can www.com.cn set the cookie to .com.cn?
Test result: No. Because the browser knows that the suffix of www.com.cn is .com.cn instead of .cn, it prohibits setting cookies.
Because the browser has a built-in domain name suffix list. todo: If a new suffix appears in the future and the old browser cannot update the list, will it allow cookies to be set?
extension后缀 | 一级域名 | 二级域名 | |
www.g.cn | .cn | g.cn | *.g.cn |
www.com.cn | .com.cn | www.com.cn | *.www.com.cn |
www.google.com.cn | .com.cn | google.com.cn | *.google.com.cn |
HTTP请求域名 | 一级域名 | cookie可设置(并可读取)的范围 | cookie不可设置 | cookie不可读取 |
example.com | example.com | example.com,.example.com | www.example.com | www.example.com |
www.example.com | example.com | www.example.com,.www.example.com,.example.com | example.com | example.com |
g.com.cn | g.com.cn | g.com.cn,.g.com.cn | .com.cn | |
www.com.cn | www.com.cn | www.com.cn,.www.com.cn | .com.cn |