简体   繁体   中英

PHP : Bind Cookie set on Subdomain to Main Domain and all Subdomains

I'm using this login script, http://tutorialzine.com/2009/10/cool-login-system-php-jquery/

I'm setting a cookie on encrypted.site.com, but I also want it to function on site.com and *.site.com. How could I do this?

It sets 2 cookies, tzLogin & tzRemember, one permanent, one session cookie.

Set the 5th parameter (domain) to allow for any subdomains by prefixing a period. This will allow requests for site1.site.com , site2.site.com as well as site.com to send the cookie along:

setcookie('cookiename', 'cookiedata', time()+86400, '/', '.site.com');

http://us.php.net/manual/en/function.setcookie.php

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