<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$TOC_DEPRECATED = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.session.inc";
$setup = array (
  'home' => 
  array (
    0 => 'index.php',
    1 => 'PHP Manual',
  ),
  'head' => 
  array (
    0 => 'UTF-8',
    1 => 'en',
  ),
  'this' => 
  array (
    0 => 'function.session-cache-expire.php',
    1 => 'session_cache_expire',
    2 => 'Get and/or set current cache expire',
  ),
  'up' => 
  array (
    0 => 'ref.session.php',
    1 => 'Session Functions',
  ),
  'prev' => 
  array (
    0 => 'function.session-abort.php',
    1 => 'session_abort',
  ),
  'next' => 
  array (
    0 => 'function.session-cache-limiter.php',
    1 => 'session_cache_limiter',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'en',
    'path' => 'reference/session/functions/session-cache-expire.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.session-cache-expire" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">session_cache_expire</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.2.0, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">session_cache_expire</span> &mdash; <span class="dc-title">Get and/or set current cache expire</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.session-cache-expire-description">
  <h3 class="title">Description</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>session_cache_expire</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.integer.php" class="type int">int</a></span></span> <code class="parameter">$value</code><span class="initializer"> = <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong></span></span>): <span class="type"><span class="type"><a href="language.types.integer.php" class="type int">int</a></span>|<span class="type"><a href="language.types.singleton.php" class="type false">false</a></span></span></div>

  <p class="para rdfs-comment">
   <span class="function"><strong>session_cache_expire()</strong></span> returns the current setting of
   <code class="literal">session.cache_expire</code>. 
  </p>
  <p class="para">
   The cache expire is reset to the default value of 180 stored in
   <a href="session.configuration.php#ini.session.cache-expire" class="link">session.cache_expire</a>
   at request startup time. Thus,
   you need to call <span class="function"><strong>session_cache_expire()</strong></span> for every
   request (and before <span class="function"><a href="function.session-start.php" class="function">session_start()</a></span> is called).
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.session-cache-expire-parameters">
  <h3 class="title">Parameters</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">
       If <code class="parameter">value</code> is given and not <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, the current cache
       expire is replaced with <code class="parameter">value</code>.
      </p>
      <p class="para">
       <blockquote class="note"><p><strong class="note">Note</strong>: 
        <span class="simpara">
         Setting <code class="parameter">value</code> is of value only, if
         <code class="literal">session.cache_limiter</code> is set to a value
         <em>different</em> from <code class="literal">nocache</code>.
        </span>
       </p></blockquote>
      </p>
     </dd>
    
   </dl>
  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.session-cache-expire-returnvalues">
  <h3 class="title">Return Values</h3>
  <p class="para">
   Returns the current setting of <code class="literal">session.cache_expire</code>.
   The value returned should be read in minutes, defaults to 180.
   On failure to change the value, <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong> is returned.
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.session-cache-expire-changelog">
  <h3 class="title">Changelog</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>Version</th>
      <th>Description</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">value</code> is nullable now.
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.session-cache-expire-examples">
  <h3 class="title">Examples</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>Example #1 <span class="function"><strong>session_cache_expire()</strong></span> example</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">/* set the cache limiter to 'private' */<br /><br /></span><span style="color: #0000BB">session_cache_limiter</span><span style="color: #007700">(</span><span style="color: #DD0000">'private'</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cache_limiter </span><span style="color: #007700">= </span><span style="color: #0000BB">session_cache_limiter</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">/* set the cache expire to 30 minutes */<br /></span><span style="color: #0000BB">session_cache_expire</span><span style="color: #007700">(</span><span style="color: #0000BB">30</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$cache_expire </span><span style="color: #007700">= </span><span style="color: #0000BB">session_cache_expire</span><span style="color: #007700">();<br /><br /></span><span style="color: #FF8000">/* start the session */<br /><br /></span><span style="color: #0000BB">session_start</span><span style="color: #007700">();<br /><br />echo </span><span style="color: #DD0000">"The cache limiter is now set to </span><span style="color: #0000BB">$cache_limiter</span><span style="color: #DD0000">&lt;br /&gt;"</span><span style="color: #007700">;<br />echo </span><span style="color: #DD0000">"The cached session pages expire after </span><span style="color: #0000BB">$cache_expire</span><span style="color: #DD0000"> minutes"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-function.session-cache-expire-seealso">
  <h3 class="title">See Also</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="session.configuration.php#ini.session.cache-expire" class="link">session.cache_expire</a></li>
    <li><a href="session.configuration.php#ini.session.cache-limiter" class="link">session.cache_limiter</a></li>
    <li><span class="function"><a href="function.session-cache-limiter.php" class="function" rel="rdfs-seeAlso">session_cache_limiter()</a> - Get and/or set the current cache limiter</span></li>
   </ul>
  </p>
 </div>


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