Sharing cookie between two sites

From Logic Wiki
Revision as of 14:27, 9 May 2016 by Dt1nh6 (Talk | contribs) (1 revision imported)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search


If they are in different domains

It's impossible to write a cookie from one domain and read it from other one.

So my approach was to create a cookie on one site and call the other site with a parameter in background.

On the other site we can create a cookie with that parameter.

If they are in same domain but in different sub domains

in c# we create them as it is

 var userCookie = new HttpCookie("UserCookie");
 userCookie.Values.Add("username", firstName);
 userCookie.Values.Add("signouturl", HttpContext.Current.Request.Url.Scheme + "://" + HttpContext.Current.Request.Url.Authority + OpteviaPortal.Navigation.GetUrlForSiteMarker("Account - Logout"));
 userCookie.Domain = ConfigurationManager.AppSettings["CookieDomain"];
 userCookie.Path = "/";
 Response.Cookies.Add(userCookie);

we don't add expiry to destroy cookie when browser window closed