简体   繁体   English

在不注销用户会话的情况下重新启动服务器

[英]Restart server without logout user session

I am using JBoss server. 我正在使用JBoss服务器。 I have one problem with session. 我的会话有一个问题。 After logged in to the page again I restarted server. 再次登录页面后,我重新启动了服务器。 But user session is getting logged out. 但是用户会话正在注销。 Again It redirects to login page. 再次它将重定向到登录页面。 I need to allow user to see the webpage without logout. 我需要允许用户无需注销即可查看该网页。

After restarting the server, your login session information is lost. 重新启动服务器后,您的登录会话信息将丢失。 You need to persist it to avoid this. 您需要坚持下去以避免这种情况。

https://community.jboss.org/wiki/HAWebSessionsViaDatabasePersistence looks like exactly this. https://community.jboss.org/wiki/HAWebSessionsViaDatabasePersistence看起来就是这样。

When you restart the application server, all the sessions will be terminated, that is a normal thing, because sessions are kept in the memory to put it simply. 重新启动应用程序服务器时,所有会话都将终止,这很正常,因为将会话保留在内存中只是为了简单起见。

If you want the user to continue on from his previous session, you will have to go through a lot of trouble such as re-creating the session objects and populate them with the data you somehow saved from last session, and a way to authenticate the user without the user entering his password again. 如果您希望用户继续上一个会话,则将遇到很多麻烦,例如重新创建会话对象,并使用您从上一个会话中保存的数据填充它们,以及对用户进行身份验证的方法。用户,而无需再次输入密码。 That is probably the easy part which you can achieve by storing the session identifier in a cookie and keeping track of it in a database or text file, but re-creating the session itself exactly from where you left off might not be a good or even practical idea. 这可能是简单的部分,您可以通过将会话标识符存储在cookie中并在数据库或文本文件中对其进行跟踪来实现,但是准确地从中断的地方重新创建会话本身可能不是一个好选择,甚至实用的想法。

Two options for storing and restoring the session: 存储和还原会话的两个选项:

1) Save the data related to the session (items in a shopping cart for instance) in a database or a text file of some sort. 1)将与会话相关的数据(例如,购物车中的项目 )保存在数据库或某种文本文件中。 (save it on the hard disk) This will prove very difficult, how difficult depending on the complexity of your site. (将其保存在硬盘上)这将非常困难,具体取决于您站点的复杂程度。

2) Save the users session data in a cookie along with the session identifier (jsessionid) . 2)将用户会话数据以及会话标识符(jsessionid)保存在cookie中。 Again you will need to do some custom work, identifying these cookies and reading them. 同样,您将需要做一些自定义工作,识别这些cookie并阅读它们。 User can always get rid of cookies, or disable them etc. 用户总是可以摆脱cookie,或禁用它们等。

If you have a very simple web page that doesn't include any data other than the authentication, you simply want to see the previous page you were at, you can save a cookie in the client identifying the user and the page he was last at. 如果您有一个非常简单的网页,除了身份验证以外不包含任何数据,您只想查看您所在的上一页,则可以在客户端中保存一个cookie,以标识用户和他上次访问的页面。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM