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
Copy
vcr.getGlobalSession()
Getting your Global Session
Copy
vcr.getGlobalSession();
Copy
vcr.getGlobalSession()
Get Session by ID
If you have a session ID you can use it to retrieve a session.
Method Signature
Copy
vcr.getSessionById(id: string)
Getting your Session by ID
Copy
vcr.getSessionById('my-session');
Copy
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
Copy
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
Copy
vcr.getSessionFromRequest(req.body);
Copy
vcr.getSessionFromRequest(request)