public class CrossDomainCookie : IHttpModule
{
private string m_RootDomain = string.Empty; #region IHttpModule Members public void Dispose()
{ } public void Init(HttpApplication context)
{
m_RootDomain = ConfigurationManager.AppSettings["RootDomain"]; Type stateServerSessionProvider = typeof(HttpSessionState).Assembly.GetType("System.Web.SessionState.OutOfProcSessionStateStore");
FieldInfo uriField = stateServerSessionProvider.GetField("s_uribase", BindingFlags.Static | BindingFlags.NonPublic); if (uriField == null)
throw new ArgumentException("UriField was not found"); uriField.SetValue(null, m_RootDomain); context.EndRequest += new System.EventHandler(context_EndRequest);
} void context_EndRequest(object sender, System.EventArgs e)
{
HttpApplication app = sender as HttpApplication; for (int i = ; i < app.Context.Response.Cookies.Count; i++)
{
app.Context.Response.Cookies[i].Domain = m_RootDomain;
}
} #endregion
}

config里面配置:(注意两个站点都要配置)

 <configuration>
<appSettings>
<add key="RootDomain" value=".session.com"/>
</appSettings>
<connectionStrings/>
<system.web>
<machineKey decryptionKey="FD69B2EB9A11E3063518F1932E314E4AA1577BF0B824F369" validationKey="5F32295C31223A362286DD5777916FCD0FD2A8EF882783FD3E29AB1FCDFE931F8FA45A8E468B7A40269E50A748778CBB8DB2262D44A86BBCEA96DCA46CBC05C3" validation="SHA1" decryption="Auto"/>
<sessionState cookieless="false" timeout="" mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424"/>
<httpModules>
<add name="CrossDomainCookieModule" type="WebLibrary.CrossDomainCookie, WebLibrary"/>
</httpModules>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
</system.web>
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
<system.webServer>
<modules>
<add name="CrossDomainCookieModule" preCondition="managedHandler" type="WebLibrary.CrossDomainCookie, WebLibrary"/>
</modules>
</system.webServer>
</configuration>

最新文章

  1. 【转】DBMS_STATS.GATHER_TABLE_STATS详解
  2. Message
  3. 2.PHP内核探索:一次请求的开始与结束
  4. ios blog
  5. App架构设计学习(一)---- 接口的设计
  6. 函数fsp_alloc_from_free_frag
  7. RTC搭建android下三层应用程序访问服务器MsSql-服务器端
  8. 通过使用CyclicBarrier来计算Matrix中最大的值
  9. 用户输出表单处理php
  10. 体验CSDN-Markdown
  11. [daily]gtk程序不跟随系统的dark主题
  12. [NOI2010]超级钢琴(RMQ+堆)
  13. python网络编程基础(线程与进程、并行与并发、同步与异步、阻塞与非阻塞、CPU密集型与IO密集型)
  14. 微信小程序实现简单的树形图treeview
  15. windows安装 centos
  16. wget命令的使用
  17. [POI2013]Polaryzacja
  18. 如何用dat批处理文件关闭某端口对应程序-Windows自动化命令
  19. 解决 Attempting to destroy the window while drawing!
  20. 【WPF】给UserControl引入多个资源

热门文章

  1. 《modern operating system》 chapter 6 DEADLOCKS 笔记
  2. mysql最新版中文参考手册在线浏览
  3. Cocos从入门到精通--《创建第一个项目:HelloWorld》
  4. Oracle imp exp命令具体解释
  5. [读书笔记]流畅的Python(Fluent Python)
  6. VS创建Web项目提示配置IISExpress失败
  7. C项目实践--图书管理系统(4)
  8. python操作dataFrame
  9. 【HDU 1520】 Anniversary Party
  10. OAuth学习总结