mongodb/mongo-php-driver

Get session timeout from session object

719media opened this issue · 1 comments

It appears in mongo documentation that there is a way to get the session timeout when starting a session:
https://docs.mongodb.com/manual/reference/command/startSession/
output: timeoutMinutes

In default setup, this value would be expected to be approximately 30 minutes from the current time.

In mongo php library, the start session method:
https://docs.mongodb.com/php-library/current/reference/method/MongoDBClient-startSession/

Returns a session object. However, this session object does not appear to have this timeoutMinutes value stored anywhere. It would be useful to obtain this value to get the expected timeout of a session, in case the db config is different than 30 minutes

Quoting the startSession section of the driver sessions spec:

Drivers SHOULD generate session IDs locally if possible instead of running the startSession command, since running the command requires a network round trip.

Most drivers (including PHP and libmongoc) do not use the startSession command. Instead, they generate session IDs locally (see: mongoc_client_start_session) and the server, upon seeing an ID for the first time, creates a server-side session automatically.

If you do need to access localLogicalSessionTimeoutMinutes from your application, I believe you can invoke the getParameter command manually.