.\" Man page generated from reStructuredText. . .TH "MONGOC_CLIENT_START_SESSION" "3" "Feb 23, 2019" "1.14.0" "MongoDB C Driver" .SH NAME mongoc_client_start_session \- mongoc_client_start_session() . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .SH SYNOPSIS .INDENT 0.0 .INDENT 3.5 .sp .nf .ft C mongoc_client_session_t * mongoc_client_start_session (mongoc_client_t *client, mongoc_session_opt_t *opts, bson_error_t *error) .ft P .fi .UNINDENT .UNINDENT .sp Create a session for a sequence of operations. .sp Start a session with \fBmongoc_client_start_session\fP, use the session for a sequence of operations and multi\-document transactions, then free it with \fBmongoc_client_session_destroy()\fP\&. Any \fBmongoc_cursor_t\fP or \fBmongoc_change_stream_t\fP using a session must be destroyed before the session, and a session must be destroyed before the \fBmongoc_client_t\fP it came from. .sp By default, sessions are \fI\%causally consistent\fP\&. To disable causal consistency, before starting a session create a \fBmongoc_session_opt_t\fP with \fBmongoc_session_opts_new()\fP and call \fBmongoc_session_opts_set_causal_consistency()\fP, then free the struct with \fBmongoc_session_opts_destroy\fP\&. .sp Unacknowledged writes are prohibited with sessions. .sp A \fBmongoc_client_session_t\fP must be used by only one thread at a time. Due to session pooling, \fBmongoc_client_start_session\fP may return a session that has been idle for some time and is about to be closed after its idle timeout. Use the session within one minute of acquiring it to refresh the session and avoid a timeout. .SH PARAMETERS .INDENT 0.0 .IP \(bu 2 \fBclient\fP: A \fBmongoc_client_t\fP\&. .IP \(bu 2 \fBopts\fP: An optional \fBmongoc_session_opt_t\fP\&. .IP \(bu 2 \fBerror\fP: A \fI\%bson_error_t\fP\&. .UNINDENT .SH RETURNS .sp If successful, this function returns a newly allocated \fBmongoc_client_session_t\fP that should be freed with \fBmongoc_client_session_destroy()\fP when no longer in use. On error, returns NULL and sets \fBerror\fP\&. .SH ERRORS .sp This function can fail if the driver is not built with crypto support, if \fBopts\fP is misconfigured, or if the session is configured with options that the server does not support. .SH AUTHOR MongoDB, Inc .SH COPYRIGHT 2017-present, MongoDB, Inc .\" Generated by docutils manpage writer. .