<?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 => 'zh',
  ),
  'this' => 
  array (
    0 => 'function.session-cache-limiter.php',
    1 => 'session_cache_limiter',
    2 => '读取/设置缓存限制器',
  ),
  'up' => 
  array (
    0 => 'ref.session.php',
    1 => 'Session 函数',
  ),
  'prev' => 
  array (
    0 => 'function.session-cache-expire.php',
    1 => 'session_cache_expire',
  ),
  'next' => 
  array (
    0 => 'function.session-commit.php',
    1 => 'session_commit',
  ),
  'alternatives' => 
  array (
  ),
  'source' => 
  array (
    'lang' => 'zh',
    'path' => 'reference/session/functions/session-cache-limiter.xml',
  ),
  'history' => 
  array (
  ),
);
$setup["toc"] = $TOC;
$setup["toc_deprecated"] = $TOC_DEPRECATED;
$setup["parents"] = $PARENTS;
manual_setup($setup);

contributors($setup);

?>
<div id="function.session-cache-limiter" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">session_cache_limiter</h1>
  <p class="verinfo">(PHP 4 &gt;= 4.0.3, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">session_cache_limiter</span> &mdash; <span class="dc-title">读取/设置缓存限制器</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.session-cache-limiter-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>session_value</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.string.php" class="type string">string</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.string.php" class="type string">string</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_limiter()</strong></span> 返回当前缓存限制器的名称。
  </p>
  <p class="para">
    缓存限制器定义了向客户端发送的 HTTP 响应头中的缓存控制策略。
    客户端或者代理服务器通过检测这个响应头信息来
    确定对于页面内容的缓存规则。
    设置缓存限制器为 <code class="literal">nocache</code> 会禁止客户端或者代理服务器缓存内容，
    <code class="literal">public</code> 表示允许客户端或代理服务器缓存内容，
    <code class="literal">private</code> 表示允许客户端缓存，
    但是不允许代理服务器缓存内容。
  </p>
  <p class="para">
   在 <code class="literal">private</code> 模式下， 包括 <span class="productname">Mozilla</span> 
   在内的一些浏览器可能无法正确处理 Expire 响应头，
   通过使用 <code class="literal">private_no_expire</code> 模式可以解决这个问题：在这种模式下，
   不会向客户端发送 <code class="literal">Expire</code> 响应头。
  </p>
  <p class="para">
    设置为  <code class="literal">&#039;&#039;</code> 可以关闭
    自动发送缓存策略响应头的功能。
  </p>
  <p class="para">
    请求开始的时候，缓存限制器会被重置为默认值，并且存储在
    <a href="session.configuration.php#ini.session.cache-limiter" class="link">session.cache_limiter</a> 
    配置项中。
    因此，如果要设置缓存限制器，对于每个请求，
    都需要在调用 <span class="function"><a href="function.session-start.php" class="function">session_start()</a></span> 函数之前，
    调用 <span class="function"><strong>session_cache_limiter()</strong></span> 函数来进行设置。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.session-cache-limiter-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>
    
     <dt><code class="parameter">value</code></dt>
     <dd>
      <p class="para">
       如果指定 <code class="parameter">value</code> 且不为 <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>，
       将使用指定值作为缓存限制器的值。
      </p>
      <table class="doctable table">
       <caption><strong>可选的值</strong></caption>
       
        <thead>
         <tr>
          <th>值</th>
          <th>发送的响应头</th>
         </tr>

        </thead>

        <tbody class="tbody">
         <tr>
          <td><code class="literal">public</code></td>
          <td>
           <div class="example-contents">
<div class="headercode"><pre class="headercode">Expires: (sometime in the future, according session.cache_expire)
Cache-Control: public, max-age=(sometime in the future, according to session.cache_expire)
Last-Modified: (the timestamp of the current script)</pre>
</div>
           </div>

          </td>
         </tr>

         <tr>
          <td><code class="literal">private_no_expire</code></td>
          <td>
           <div class="example-contents">
<div class="headercode"><pre class="headercode">Cache-Control: private, max-age=(session.cache_expire in the future)
Last-Modified: (the timestamp of the current script)</pre>
</div>
           </div>

          </td>
         </tr>

         <tr>
          <td><code class="literal">private</code></td>
          <td>
           <div class="example-contents">
<div class="headercode"><pre class="headercode">Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: private, max-age=(session.cache_expire in the future)
Last-Modified: (the timestamp of the current script)</pre>
</div>
           </div>

          </td>
         </tr>

         <tr>
          <td><code class="literal">nocache</code></td>
          <td>
           <div class="example-contents">
<div class="headercode"><pre class="headercode">Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache</pre>
</div>
           </div>

          </td>
         </tr>

        </tbody>
       
      </table>

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


 <div class="refsect1 returnvalues" id="refsect1-function.session-cache-limiter-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回当前所用的缓存限制器名称。如果更改值失败，则返回 <strong><code><a href="reserved.constants.php#constant.false">false</a></code></strong>。
  </p>
 </div>


 <div class="refsect1 changelog" id="refsect1-function.session-cache-limiter-changelog">
  <h3 class="title">更新日志</h3>
  <table class="doctable informaltable">
   
    <thead>
     <tr>
      <th>版本</th>
      <th>说明</th>
     </tr>

    </thead>

    <tbody class="tbody">
     <tr>
      <td>8.0.0</td>
      <td>
       <code class="parameter">value</code> 现在可为 null。
      </td>
     </tr>

    </tbody>
   
  </table>

 </div>


 <div class="refsect1 examples" id="refsect1-function.session-cache-limiter-examples">
  <h3 class="title">示例</h3>
  <p class="para">
   <div class="example" id="example-1">
    <p><strong>示例 #1 <span class="function"><strong>session_cache_limiter()</strong></span> 示例</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">/* 设置缓存限制器为 '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 />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 /></span><span style="color: #0000BB">?&gt;</span></span></code></div>
    </div>

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


 <div class="refsect1 seealso" id="refsect1-function.session-cache-limiter-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li><a href="session.configuration.php#ini.session.cache-limiter" class="link">session.cache_limiter</a></li>
   </ul>
  </p>
 </div>


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