Setcookie (), the fifth parameter in the domain name parameter domain
If this parameter is. domain.com then this cookie can be obtained from the primary domain name or any subdomain. Under the same domain name. Sub-domains can be shared with each other. But not the same domain name can not be shared directly.
Different (primary) domain names can be nested to generate cookies directly, through the page a domain name under the B domain name of the connection, resulting in a B domain name cookie. But they cannot be shared directly with each other.
Nested methods may be blocked under IE, and different browsers have different permissions to generate cookies for third parties. So using P3P to open IE allows third parties to generate cookies.
SSO Single Sign-on
After a log-in, a sign is generated with this flag to access B (to determine if the login is successful), and then obtain the data.
As long as SessionID knows, you can find the link pool. Login status
Sub-domain setcooke.php
<?php//If login succeeded//Generate a shared Cookie$gongxiang = "Zhuliuyang" under Subdomain, Setcookie ("Gongxiang", $gongxiang, Time () +3600, "/", " . cs.com ");//Set Shared cookiesession_id ($gongxiang);//Set Session_idsession_start ();//Open session$_session[' islogin '] = ' 1 '; Echo ' set success ';
Determine whether to log in under the primary domain name
Operation Result:
After clearing the cookie. is an empty array of two.
The same principle is true for different primary domains. The premise is on the same server. Not on the same server, then the session connection pool will not be found.
On different servers, you can log in to the database or file. To judge again.
(not to be continued)
Single Sign-on SSO, cookie cross-domain