.
This works great for sharing session cookie between example1.com subdomains. Unfortunately, this completely screws up session state for *.example2.com.
Any ideas on how I can solve this?
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(3)
您是否尝试过创建一个
HttpModule
来拦截EndRequest
事件,迭代Response.Cookies
集合,查找会话cooke并更改其在实际将其发送到客户端之前的Domain
属性。编辑:
Kevin 最后确定其中一个子域在 ie8 中处于受信任状态,而另一个则不是。当两者都处于受信任状态(并且可能都处于不受信任状态)时,它就可以工作。我确实在这个问题上花了最多的时间,所以凯文想把答案归功于我。
Have you tried creating a
HttpModule
that intercepts theEndRequest
-event, iterates over theResponse.Cookies
collection, finds the session-cooke and changes itsDomain
property before actually sending it to the client.Edit:
Kevin at the end determined that one of the subdomains was in a trusted state in ie8 while the other was not. When both are in a trusted state (and presumambly both in an untrusted state) it works. I did spent the most time on this, so Kevin want to give me the credit for the answer.
不要使用 SiteUtility.GetCookieDomain(),而是尝试使用:
rather than using SiteUtility.GetCookieDomain(), try using:
第一种方法,
将会话作为文件存储在两个服务器都可以访问的位置(这对于虚拟服务器或共享文件夹很有用)。这种方法有点不可靠,并且共享文件夹和滞后从而导致问题。
好吧,我本来打算写一些其他方法,但我确信它们会被发布,因为他们比我对 ASP.NET 有更多的了解,但是,我确实有个人偏好,我认为这将是一个不错的选择。
这个选项是一个内存缓存服务器。本质上,它是一个使用 RAM 运行的数据库,您将所有会话都指向它(tcp://mem.domain.com:1234 ...抱歉,我不记得通常的端口了)。
我希望我能帮上忙,
乔恩
First way,
Store session as file in a location that both servers can access (this is good for virtual servers or shared folders). This method is a bit unreliable and shared folders and lag thus causing problems.
Okay, I was going to write a couple of other methods but I'm sure they'll be posted as they have more knowledge with asp.net than I, however, I do have a personal preference that I think would be a good option.
This option would be a memcache server. Essentially it's a database that runs off RAM and you point all of your sessions to it (tcp://mem.domain.com:1234 ... sorry I can't remember the usual port off the top of my head).
I hope I was of some help,
Jon