Reputation: 68962
I have 2 website on my IIS7, I can put the same domain for both of them, I want some cookies of both applications to be shared between them, so than I can create the cookie from one of them and read it from the other one, is that possible? do I need any custom configurations to do that?
note: My websites, 1 is asp.net forms website and the other is MVC.
Upvotes: 1
Views: 2356
Reputation: 440
yes if there are appending cookie not only add
like: Response.AppendCookie(your cookie name)
Remember that if it is in asp.net web site then you can get cookie by
string a = Request.Cookies["Your Cookie Name"].Value
some thing like that
Upvotes: 0
Reputation: 19238
If both applications are in top level, there is no need for any custom configuration but if any of the application is in sub domain, than you have properly set cookie so that sub-domains can access that. In that case, following web.config modification is needed.
<httpCookies domain=".yourdomain.com" />
Upvotes: 1
Reputation: 1038930
When you create the cookie specify the domain:
var cookie = new HttpCookie("foo", "bar")
{
// indicates that only server side scripts can read this cookie
HttpOnly = true,
// indicates that the cookie will be available throughout the entire domain
Domain = "example.com"
};
Response.AppendCookie(cookie);
Now on the other application you will be able to access this cookie (assuming of course it is running on the same domain):
var cookie = Request.Cookies["foo"];
Upvotes: 2
Reputation: 887509
Cookies are sent by the client to any URL in the cookie's domain (and optional path).
They have nothing to do with the server-side application; as long as the application is in the cookie's domain name and path, it will receive all cookies.
Upvotes: 1