-->

Android Session getting lost in IBM Websphere Serv

2020-07-18 08:39发布

问题:

Whenever i hit the login page from an android device , a session has to be created and maintained until the user hits log out button.. But there seem to be a weird problem with IBM Websphere Servers .. i am able to login successfully but when i try to request some other data the session is getting lost from the server , this is not the case with server running on Apache TomCat .. also in iOS Devices its working fine !

Example : 1. user logs in -> creates a session for this user 2. Android App hits the server continously with 1 sec interval 3. user logs out -> user is loggged out successfully

this flow is going proper in case of Apache TomCat , but in case of Websphere at step 2 .. the session is getting lost , because of which the user cant even log out

what could be the issue ? is there something i could be missing on server side ? or is it websphere has compatibility issue ?

回答1:

This issue needs to be solved in 2 parts

  1. Android Side

    Android HttpPost by default doesn't send necessary headers , so we need to add headers explicitly , of which the most important is JSESSIONID when your dealing with session management for android with Websphere Servers .. all you got to do is get the JESSIONID from Server Reponse and attach it to any further request that you make to the server .

  2. Websphere

Websphere needs to be set with important property , which can be achieved by following steps :

a. Open the administrative console.

b. Select Servers > Application Servers > Server_Name > Server Infrastructure > Java and Process Management > Process Definition > Java Virtual Machine > Custom Properties > New.

c. Add a new Custom Property for the JVM to reuse the sessionId: System Property Name: HttpSessionIdReuse System Property Value: true

d. Save your changes and restart the Application Server.