Well, the out-of-proc StateServer works just fine for sharing sessions across
sub-domains. Everything in ASP.NET allows for sharing sessions across
sub-domains; everything except this simple cookie issue.
Let me explain one of the reasons why I need sessions to be shared across
sub-domains:
I have a "www" server, and a "search" server. When a person signs in, the
HTML header at the top of every page shows a link to "Sign Out". This same
header is used on every page throughout the site; on both "www" and "search".
Based on the session, I know whether the person is signed in or not, and
whether to show the "Sign Out" link or not. The session needs to persist
across sub-domains; otherwise, when a person goes to the "search" server,
they wouldn't appear to be signed in any longer.
There are many real-world examples of why sessions need to be shared across
sub-domains. e.g. Yahoo uses a single sign-on and you stay signed-in across
"mail.yessy.com", "shopping.yahoo.com", "music.yahoo.com", etc.
There are just so many examples of why a session would need to be shared
across sub-domains.
The ASP.NET StateServer natively supports sub-domains. The only issue is the
domain setting for the Session cookie. Instead of tying the cookie to
"www.mydomain.com", allow the cookie to be tied to "mydomain.com". That way,
all sub-domains can access the cookie and problem solved. People stay
signed-in across sub-domains; the same session can be accessed; etc.
Why not allow developers to share sessions across sub-domains if they need
to? It's an extremely simple feature to provide.
By the way, I implemented a fairly good fix/hack today. Put this code on
every page:
Response.Cookies["ASP.NET_SessionId"].Value = Session.SessionID;
Response.Cookies["ASP.NET_SessionId"].Domain = ".mydomain.com";
Those two lines of code rewrite the Session cookie so it's now accessible
across sub-domains.
My hope is that Microsoft will implement a web/machine.config param that
allows the Session cookie to be accessed across sub-domains.
Doug
"John Timney (ASP.NET MVP)" wrote:
I expect the problem would be the same. Asp.net bounds sessions and objects
within applications for security, so if your subdomains were not part of the
same web application then the session would not apply. The solution could
be to have a root application, with all your other applications hanging
under it as non application virtual directories - and then have something
like the isapi virtual hosting filter handle the domains, allowing the root
application to own the single session. I've never tried it myself though.
I would always see a sub-domain as a seperate application entirely, or why
would it be a sub-domain?
--
Regards
John Timney
ASP.NET MVP
Microsoft Regional Director
"Doug" <Do**@discussions.microsoft.com> wrote in message
news:BD**********************************@microsof t.com... Hi John,
I wasn't referring to sharing sessions across parent domains (e.g.
"mydomain1.com" and "mydomain2.com"). I want to share sessions on
sub-domains
of the same domain (e.g. "www.mydomain.com" and "search.mydomain.com").
Regards,
Doug
"John Timney (ASP.NET MVP)" wrote:
sorry I misread your question (its late here!!).
You can't share sessions across domains, nor applications natively - so
it
will always set a new cookie as you move between domains. Because you
can
share cookies across those applications (and between those domains) one
approach is to store your shared data in a database and use a shared
domain
cookie to identify the data in the database.
--
Regards
John Timney
ASP.NET MVP
Microsoft Regional Director