第一種模式:同一頂級域名下cookie共享,代碼如下
HttpCookie cookies = new HttpCookie("Token"); cookies.Expires = DateTime.Now.AddDays(7); cookies.Path = "/"; cookies.Domain = "xxxx.com";//設置同一頂級域名 cookies.Value = "token的值"; System.Web.HttpContext.Current.Response.Cookies.Add(cookies);
第二種模式:跨域下實現單點登錄