How do you implement the login, user information is used for multiple sites?

xiaoxiao2021-03-14  190

I use Domain to solve the problem of reading different sites cookie http://www.microsoft.com/china/msdn/archives/library/dv_vstechart/html/vbtchaspnetCookies101.asp ============ ============================================================================================================================================================================================================= ======= You can also use the Domain property to create cookies that can be shared in multiple subdomains. For example, the domain is set as follows: Response.Cookies ("domain"). Value = DateTime.now.tostring response.cookies ("domain"). Expires = datetime.now.adddays (1) Response.cookies ("Domain" This cookie can be used in the primary domain, Sales.Contoso.com and support.contoso.com ==================== ============================================================================================================================================================================================================= This approach is only suitable for sites between the same domain, and cannot simply solve data information between different sites, but this method is very simple, plus a line of code.

-------------------------------------------------- -------------------------------------------------- ---------------------

About Sub-Domains of A Single Domain shares a SESSION solution

//

******

//

Judging whether the cookie exists

IF

(Request.cookies [

"

Remrember

"

]

! =

NULL

&&&&

REQUEST.COOKIES [

"

Remrember

"

] [

"

Username

"

]

! =

NULL

)

{}

//

******

//

******

//

Solution for multi-site sharing session

Response.cookies [

"

Remrember

"

] [

"

Username

]

=

Session [

"

UserID

"

] .ToString (); Response.cookies [

"

Remrember

"

] .Domain

=

"

8bao.com

"

;

//

The essential

Response.cookies [

"

Remrember

"

] .Expires

=

Datetime.now.adddays

1

);

//

Cannot ignore

//

******

Generated cookie (IE => Tool => Internet Option => General => Settings => View File): Cookie Name: Cookie: Administrator@8bao.com/ cookie content: Remrember Username = xiaodi 8bao.com/ 1536 176565968592 29704748 *

//

******

//

Delete shared session cookies

HTTPCOOKIE COOKIE

=

REQUEST.COOKIES [

"

Remrember

"

Cookie.expires

=

DateTime.today.Adddays

-

10

Cookie.domain

=

"

8bao.com

"

;

//

The essential

Response.cookies.add (cookie);

//

******

Remove the Cookie Supplement: Delete the cookie (ie, the cookie is physically deleted on the user's hard disk). Since cookies is located in a user's computer, you can't delete it directly. However, you can let your browser delete cookies for you. It is to set it to a certain date in the past. When the browser checks the validity of the cookie, this expired cookie will be removed. Reference: http://www.15seconds.com/issue/971108.htm

转载请注明原文地址:https://www.9cbs.com/read-129215.html

New Post(0)