多台服务之间共享Session

一.问题:为了满足足够大的应用,满足更多的客户,就需要架设N台Web服务器(N>=2),在多台Web服务器的情况下,就会涉及到一个问题:用户登陆一台服务器以后,如果在跨越到另一台服务器的时候能够继续使用客户的Session?

二.解决方案:使用session服务器

1.开启State Service 服务(此服务用于存储session)

2.在web.config中配置session信息(使所有session查询都指向tcpip服务器)

<system.web>
<sessionState mode="StateServer" timeout="20" cookieless="false" stateConnectionString=" tcpip=192.168.17.13:42424"/>
</system.web>

//上面代码 mode的类型有四种 Off/InProc/StateServer/SQLServer

3.参考内容(可以使用Memcache达到session的作用)

http://blog.163.com/wenchangqing_live/blog/static/17372230920130113372214/

http://blog.sina.com.cn/s/blog_5f3d71430100jv7q.html

原文地址:https://www.cnblogs.com/lwngreat/p/5420802.html