gokan
gokan

Reputation: 1078

Java - Does javax.websocket.Session and javax.servlet.http.HttpSession use the same JSESSIONID?

I would like to know if getId() method from javax.websocket.Session and getId() method from javax.servlet.http.HttpSession always share the same JSESSIONID.

NB: I know that those two methods are implementation dependent, and I didn't find a link between those two session id on the internet/documentation.

Goal: A client connects to my website (a JSESSIONID is created) and is authentified by a login/password (client object is linked to the JSESSIONID), then he uses website's chat ... will he be recognized by his session id from the websocket ?

=> If the anwser is "no, it's not always the same", could you propose an alternative solution ? Thanks

Upvotes: 1

Views: 937

Answers (1)

wero
wero

Reputation: 32980

The ids of a websocket Session and a HttpSession are not related.

A simple reason is that a client which is associated with a server side HttpSession can have multiple websocket sessions which all need an own unique id.

Upvotes: 1

Related Questions