<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/class.mongodb-driver-manager.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'it',
  ),
  'this' => 
  array (
    0 => 'mongodb-driver-manager.startsession.php',
    1 => 'MongoDB\\Driver\\Manager::startSession',
    2 => 'Start a new client session for use with this client',
  ),
  'up' => 
  array (
    0 => 'class.mongodb-driver-manager.php',
    1 => 'MongoDB\\Driver\\Manager',
  ),
  'prev' => 
  array (
    0 => 'mongodb-driver-manager.selectserver.php',
    1 => 'MongoDB\\Driver\\Manager::selectServer',
  ),
  'next' => 
  array (
    0 => 'class.mongodb-driver-command.php',
    1 => 'MongoDB\\Driver\\Command',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/mongodb/mongodb/driver/manager/startsession.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="mongodb-driver-manager.startsession" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MongoDB\Driver\Manager::startSession</h1>
  <p class="verinfo">(mongodb &gt;=1.4.0)</p><p class="refpurpose"><span class="refname">MongoDB\Driver\Manager::startSession</span> &mdash; <span class="dc-title">Start a new client session for use with this client</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mongodb-driver-manager.startsession-description">
  <h3 class="title">Descrizione</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">final</span> <span class="modifier">public</span> <span class="methodname"><strong>MongoDB\Driver\Manager::startSession</strong></span>(<span class="methodparam"><span class="type"><span class="type"><a href="language.types.null.php" class="type null">?</a></span><span class="type"><a href="language.types.array.php" class="type array">array</a></span></span> <code class="parameter">$options</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><a href="class.mongodb-driver-session.php" class="type MongoDB\Driver\Session">MongoDB\Driver\Session</a></span></div>

  <p class="simpara">
   Creates a <span class="classname"><a href="class.mongodb-driver-session.php" class="classname">MongoDB\Driver\Session</a></span> for the given
   options. The session may then be specified when executing commands, queries,
   and write operations.
  </p>
  <blockquote class="note"><p><strong class="note">Nota</strong>: 
   <span class="simpara">
    A <span class="classname"><a href="class.mongodb-driver-session.php" class="classname">MongoDB\Driver\Session</a></span> can only be used with the
    <span class="classname"><a href="class.mongodb-driver-manager.php" class="classname">MongoDB\Driver\Manager</a></span> from which it was created.
   </span>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-mongodb-driver-manager.startsession-parameters">
  <h3 class="title">Elenco dei parametri</h3>
  <dl>
   
    <dt><code class="parameter">options</code></dt>
    <dd>
     <p class="para">
      <table class="doctable table">
       <caption><strong>options</strong></caption>
       
        <thead>
         <tr>
          <th>Option</th>
          <th>Type</th>
          <th>Description</th>
          <th>Default</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td>causalConsistency</td>
          <td><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></td>
          <td>
           <span class="simpara">
            Configure causal consistency in a session. If <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, each operation
            in the session will be causally ordered after the previous read or
            write operation. Set to <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> to disable causal consistency.
           </span>
           <span class="simpara">
            See
            <a href="https://www.mongodb.com/docs/manual/core/read-isolation-consistency-recency/#causal-consistency" class="link external">&raquo;&nbsp;Casual Consistency</a>
            in the MongoDB manual for more information.
           </span>
          </td>
          <td><strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong></td>
         </tr>

         <tr>
          <td>defaultTransactionOptions</td>
          <td><span class="type"><a href="language.types.array.php" class="type array">array</a></span></td>
          <td>
           <span class="simpara">
            Default options to apply to newly created transactions. These
            options are used unless they are overridden when a transaction is
            started with different value for each option.
           </span>
           <p class="para">
            <table class="doctable table">
             <caption><strong>options</strong></caption>
             
              <thead>
               <tr>
                <th>Option</th>
                <th>Type</th>
                <th>Description</th>
               </tr>

              </thead>

              <tbody class="tbody">
               
         <tr>
          <td>maxCommitTimeMS</td>
          <td>integer</td>
          <td>
           <p class="para">
            The maximum amount of time in milliseconds to allow a single
            <code class="literal">commitTransaction</code> command to run.
           </p>
           <p class="para">
            If specified, <code class="literal">maxCommitTimeMS</code> must be a signed
            32-bit integer greater than or equal to zero.
           </p>
          </td>
         </tr>


               
         <tr>
          <td>readConcern</td>
          <td><span class="classname"><a href="class.mongodb-driver-readconcern.php" class="classname">MongoDB\Driver\ReadConcern</a></span></td>
          <td>
           <p class="para">
            A read concern to apply to the operation.
           </p>
           <p class="para">
            This option is available in MongoDB 3.2+ and will result in an
            exception at execution time if specified for an older server
            version.
           </p>
          </td>
         </tr>


               
         <tr>
          <td>readPreference</td>
          <td><span class="classname"><a href="class.mongodb-driver-readpreference.php" class="classname">MongoDB\Driver\ReadPreference</a></span></td>
          <td>
           <p class="para">
            A read preference to use for selecting a server for the operation.
           </p>
          </td>
         </tr>


               
         <tr>
          <td>writeConcern</td>
          <td><span class="classname"><a href="class.mongodb-driver-writeconcern.php" class="classname">MongoDB\Driver\WriteConcern</a></span></td>
          <td>
           <p class="para">
            A write concern to apply to the operation.
           </p>
          </td>
         </tr>


              </tbody>
             
            </table>

           </p>
           <span class="simpara">
            This option is available in MongoDB 4.0+.
           </span>
          </td>
          <td><code class="literal">[]</code></td>
         </tr>

         <tr>
          <td>snapshot</td>
          <td><span class="type"><a href="language.types.boolean.php" class="type bool">bool</a></span></td>
          <td>
           <span class="simpara">
            Configure snapshot reads in a session. If <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>, a timestamp will
            be obtained from the first supported read operation in the session
            (i.e. <code class="literal">find</code>, <code class="literal">aggregate</code>, or
            unsharded <code class="literal">distinct</code>). Subsequent read operations
            within the session will then utilize a <code class="literal">&quot;snapshot&quot;</code>
            read concern level to read majority-committed data from that
            timestamp. Set to <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> to disable snapshot reads.
           </span>
           <span class="simpara">
            Snapshot reads require MongoDB 5.0+ and cannot be used with causal
            consistency, transactions, or write operations. If
            <code class="literal">&quot;snapshot&quot;</code> is <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>,
            <code class="literal">&quot;causalConsistency&quot;</code> will default to <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>.
           </span>
           <span class="simpara">
            See
            <a href="https://www.mongodb.com/docs/manual/reference/read-concern-snapshot/#read-concern-and-atclustertime" class="link external">&raquo;&nbsp;Read Concern &quot;snapshot&quot;</a>
            in the MongoDB manual for more information.
           </span>
          </td>
          <td><strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong></td>
         </tr>

        </tbody>
       
      </table>

     </p>
    </dd>
   
  </dl>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-mongodb-driver-manager.startsession-returnvalues">
  <h3 class="title">Valori restituiti</h3>
  <p class="simpara">
   Returns a <span class="classname"><a href="class.mongodb-driver-session.php" class="classname">MongoDB\Driver\Session</a></span>.
  </p>
 </div>


 <div class="refsect1 errors" id="refsect1-mongodb-driver-manager.startsession-errors">
  <h3 class="title">Errori/Eccezioni</h3>
  <ul class="simplelist">
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> on argument parsing errors.</li>
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-invalidargumentexception.php" class="classname">MongoDB\Driver\Exception\InvalidArgumentException</a></span> if the <code class="literal">&quot;causalConsistency&quot;</code> and <code class="literal">&quot;snapshot&quot;</code> options are both <strong><code><a href="reserved.constants.php#constant.true">true</a></code></strong>.</li>
   <li>Throws <span class="classname"><a href="class.mongodb-driver-exception-runtimeexception.php" class="classname">MongoDB\Driver\Exception\RuntimeException</a></span> if the session could not be created (e.g. libmongoc does not support crypto).</li>
  </ul>
 </div>


 <div class="refsect1 changelog" id="refsect1-mongodb-driver-manager.startsession-changelog">
  <h3 class="title">Log delle modifiche</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Versione</th>
      <th>Descrizione</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>PECL mongodb 1.11.0</td>
      <td>
       <span class="simpara">
        The <code class="literal">&quot;snapshot&quot;</code> option was added.
       </span>
      </td>
     </tr>

     <tr>
      <td>PECL mongodb 1.6.0</td>
      <td>
       <span class="simpara">
        The <code class="literal">&quot;maxCommitTimeMS&quot;</code> option was added to
        <code class="literal">&quot;defaultTransactionOptions&quot;</code>.
       </span>
      </td>
     </tr>

     <tr>
      <td>PECL mongodb 1.5.0</td>
      <td>
       <span class="simpara">
        The <code class="literal">&quot;defaultTransactionOptions&quot;</code> option was added.
       </span>
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 seealso" id="refsect1-mongodb-driver-manager.startsession-seealso">
  <h3 class="title">Vedere anche:</h3>
  <ul class="simplelist">
   <li><span class="classname"><a href="class.mongodb-driver-session.php" class="classname">MongoDB\Driver\Session</a></span></li>
   <li><a href="https://www.mongodb.com/docs/manual/core/read-isolation-consistency-recency/#causal-consistency" class="link external">&raquo;&nbsp;Casual Consistency</a> in the MongoDB manual</li>
  </ul>
 </div>


</div><?php manual_footer($setup); ?>