Get Sessions

There are many ways to get existing Vonage Cloud Runtime sessions depending on your use case.

Global Session

The global session can be used when you do not want to create a new session.

Method Signature

vcr.getGlobalSession()

Getting your Global Session

vcr.getGlobalSession();

Get Session by ID

If you have a session ID you can use it to retrieve a session.

Method Signature

vcr.getSessionById(id: string)

Getting your Session by ID

vcr.getSessionById('my-session');

Get Session from a Request

If you have an incoming request from the Vonage Cloud Runtime platform which has the x-neru-sessionid header, you can use it to retrieve a session.

Method Signature

vcr.getSessionFromRequest(req: IRequest)

IRequest is an interface which is satisfied by an object which has a headers property.

Getting your Session from a Request

vcr.getSessionFromRequest(req.body);