Single Sign-on SSO, cookie cross-domain

Source: Internet
Author: User
Tags subdomain

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

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.