简体   繁体   中英

Worklight 6.1 :How to clear session on worklight server at adapter level

I am handling session on server side and i am able to manage that by using adapter side code

var cookie = WL.Server.getClientRequest().getHeader('Cookie');
    var request = WL.Server.getClientRequest();
    var session = request.getSession();
    var sessionid = session.getId();

But the problem is every time i am hitting the adapter i am getting the same session on server side. How to kill that session on adapter side so that i can create new session every time i hit the adapter.

I tried session.invalidate() but no use for me. After doing this also i am getting the same session on server side.

Please suggest what need to be done on server side or adapter side.

It will help greatly if you will explain exactly what you want to achieve. As it is, you are not explaining it clearly enough.


If you're talking about the server between the Worklight Server and the backend, then:

To get a new session with every adapter request sent to the backend, you need to set the connectAs property to endUser on the relevant procedure:

 <procedure name="getStories" connectAs="endUser"/> 

Refer to the following blog post which explains it at length: Configuring HTTP adapters for stateless/stateful backend connectivity and user identity propagation


If you're actually talking about the session creating when invoking the adapter on the client-side, then you cannot invalidate the session on the adapter-level. The only way to get a new session would be to re-open the application (assuming the session has already expired between the client and the Worklight Server, you'll then get a new session).

What you're describing is a default WL server behaviour. You'll get a new session created first time you hit the server and this session will be reused till it times out.

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