0

I have the web application. I deploy it into jetty container.

After browser restart it looses jsession id although session alive on server and redirect me to login page.

In browser I see following cookies:

enter image description here

How to know current jsessionId cookie type ?

Can I change cookie type to resolve my issue?

How to change jsessionId cookie type ?

Which type would be proper at this case ?

gstackoverflow
  • 36,709
  • 117
  • 359
  • 710

2 Answers2

0

Your session is not deleted until its expire time on the server side.

However, your "browsing session" ends when you restart your browser. Therefore your browser deletes all session based cookies, including the one grabbed from your website. As as result, you lose your old session and forced to start new session.

Check this out:

What is the best way to implement "remember me" for a website?

Community
  • 1
  • 1
bilgec
  • 171
  • 7
  • you just repeated my question. Remember me is function which allow login (latent for user) if session expires on server. I want to don't ask user to login if user just close browser – gstackoverflow Aug 03 '16 at 09:13
0

The cookie that identifies your session is JSESSIONID. See that expires attribute for that cookie is Session which means that the browser will forget it when you close it. You need to make the server set expires attribute for the cookie, that is login response should contain header similar to:

Set-Cookie: JSESSIONID=<id>; expires=Tuesday, 05-Nov-2004 08:30:09 GMT; ...

Read documentation for your authentication library to find out how to do that.

Michał Grzejszczak
  • 2,599
  • 1
  • 23
  • 28