简体   繁体   中英

Maintaining same session after browser closes and reopens in struts2

I am creating one application in struts2.

In this I am facing one challenge in session management.

What I need :

If user first time open login page in IE browser, then I want to show login.jsp page where user will enter username and password. After giving login credentials successfully, I am storing one attribute such as data in session scope using session.setAttribute("data","Hello");

Here I am using tomcat persistence JDBC base store. I am able to store session id and it's data in database.

Scenario : Due to some network problem or server problem, we restart the server forcefully. At this time may be client can close browser at their side thinking this way that I am already logged in so where I left a page, from that onward my session will start because session is persisted in database using tomcat persistence manager.

Problem : I am getting the same session with data, if I restart the server but do not close the browser. And if I close the browser after server restart I am unable to proceed with the existing session. Still my database is having the previous session data and when i am trying to display on console i am getting the previous session id but unable to skip login page process.

Please help me!

thanks.

To solve your problem you will have to work with persistent cookies. Persistent cookies are ones which are stored even after the user closes the browser. The folowing link should be helpful: Using cookies with Struts 2 and Struts

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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