为何关闭服务器后SESSION还有效
whaosoft
2009-05-19
在这里只说Tomcat的 别的还真不知道 估计也差不多
<直接启动tomcat>为何关闭TOMCAT后SESSION还有效!(用Eclipse启动tomcat不会出现这个问题) 服务器重新启动的话,会保存session到硬盘,下次启动后可以继续使用。大多数服务器默认就是这样的,比如WebLogic,只有JRun不保存session(不知道最新版的JRun怎么样了) tomcat在server.xml中有如下与session持久化相关的设置 <!-- PersistentManager: Uncomment the section below to test Persistent Sessions. saveOnRestart: If true, all active sessions will be saved to the Store when Catalina is shutdown, regardless of other settings. All Sessions found in the Store will be loaded on startup. Sessions past their expiration are ignored in both cases. maxActiveSessions: If 0 or greater, having too many active sessions will result in some being swapped out. minIdleSwap limits this. -1 means unlimited sessions are allowed. 0 means sessions will almost always be swapped out after use - this will be noticeably slow for your users. minIdleSwap: Sessions must be idle for at least this long (in seconds) before they will be swapped out due to maxActiveSessions. This avoids thrashing when the site is highly active. -1 or 0 means there is no minimum - sessions can be swapped out at any time. maxIdleSwap: Sessions will be swapped out if idle for this long (in seconds). If minIdleSwap is higher, then it will override this. This isn't exact: it is checked periodically. -1 means sessions won't be swapped out for this reason, although they may be swapped out for maxActiveSessions. If set to >= 0, guarantees that all sessions found in the Store will be loaded on startup. maxIdleBackup: Sessions will be backed up (saved to the Store, but left in active memory) if idle for this long (in seconds), and all sessions found in the Store will be loaded on startup. If set to -1 sessions will not be backed up, 0 means they should be backed up shortly after being used. To clear sessions from the Store, set maxActiveSessions, maxIdleSwap, and minIdleBackup all to -1, saveOnRestart to false, then restart Catalina. --> <!-- <Manager className="org.apache.catalina.session.PersistentManager" debug="0" saveOnRestart="true" maxActiveSessions="-1" minIdleSwap="-1" maxIdleSwap="-1" maxIdleBackup="-1"> <Store className="org.apache.catalina.session.FileStore"/> </Manager> --> 只要在想应APPLICATION里的CONTEXT里加入Manager选项即可。 改 saveOnRestart="false" |
|
幽灵线程
2009-05-20
关闭浏览器并不销毁session,
只是打开新页面或提交新请求时, 获得是一个新的session, 而找不到原来的SESSION。 每个session都有个session id, 如果新的页面或新的请求附带着原来的SESSION ID, 那么就会找到之前的SESSION。 形如: request.getContextPath()/login.do?jsessionid=XXXXXX |
|
whaosoft
2009-05-20
幽灵线程 写道 关闭浏览器并不销毁session,
只是打开新页面或提交新请求时, 获得是一个新的session, 而找不到原来的SESSION。 每个session都有个session id, 如果新的页面或新的请求附带着原来的SESSION ID, 那么就会找到之前的SESSION。 形如: request.getContextPath()/login.do?jsessionid=XXXXXX 谢谢啊 以前还真没注意呵呵 不过浏览器也保存session吗?? 最根本的session值是在服务中,存在系统的内存里?? 你说的不是浏览器的吧 应该是服务器里的吧 |