简体   繁体   中英

How to read cookie from subdomain in PHP?

Can anyone tell me how to read cookie from subdomain. I can set the cookie for subdomain but unable to read it.

Please tell me what is the syntax in PHP to read cookie from subdomain.

If you're enabled to read in other subdomain, it's probably because you didn't properly set the cookie to begin with.

$date_of_expiry=time()+ 3600; setcookie( "cookie_name", "cookie_value", $date_of_expiry, "/", "example.com" );

It's important that you put the last argument for the cookie to be available in other subdomains.

Also, the cookies must be set before page output.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM