<?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-limiter.php',
1 => 'session_cache_limiter',
2 => 'Get and/or set the current cache limiter',
),
'up' =>
array (
0 => 'ref.session.php',
1 => 'Session Functions',
),
'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' => 'en',
'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 >= 4.0.3, PHP 5, PHP 7, PHP 8)</p><p class="refpurpose"><span class="refname">session_cache_limiter</span> — <span class="dc-title">Get and/or set the current cache limiter</span></p>
</div>
<div class="refsect1 description" id="refsect1-function.session-cache-limiter-description">
<h3 class="title">Description</h3>
<div class="methodsynopsis dc-description">
<span class="methodname"><strong>session_cache_limiter</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> returns the name of the
current cache limiter.
</p>
<p class="para">
The cache limiter defines which cache control HTTP headers are sent to
the client. These headers determine the rules by which the page content
may be cached by the client and intermediate proxies. Setting the cache
limiter to <code class="literal">nocache</code> disallows any client/proxy caching.
A value of <code class="literal">public</code> permits caching by proxies and the
client, whereas <code class="literal">private</code> disallows caching by proxies
and permits the client to cache the contents.
</p>
<p class="para">
In <code class="literal">private</code> mode, the Expire header sent to the client
may cause confusion for some browsers, including <span class="productname">Mozilla</span>.
You can avoid this problem by using <code class="literal">private_no_expire</code> mode. The
<code class="literal">Expire</code> header is never sent to the client in this mode.
</p>
<p class="para">
Setting the cache limiter to <code class="literal">''</code> will turn off automatic sending
of cache headers entirely.
</p>
<p class="para">
The cache limiter is reset to the default value stored in
<a href="session.configuration.php#ini.session.cache-limiter" class="link">session.cache_limiter</a>
at request startup time. Thus, you need to call
<span class="function"><strong>session_cache_limiter()</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-limiter-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 specified and not <strong><code><a href="reserved.constants.php#constant.null">null</a></code></strong>, the name of the
current cache limiter is changed to the new value.
</p>
<table class="doctable table">
<caption><strong>Possible values</strong></caption>
<thead>
<tr>
<th>Value</th>
<th>Headers sent</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 when the session was last saved)</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 when the session was last saved)</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 when the session was last saved)</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">Return Values</h3>
<p class="para">
Returns the name of the current cache limiter.
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-limiter-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-limiter-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_limiter()</strong></span> example</strong></p>
<div class="example-contents">
<div class="phpcode"><code><span style="color: #000000"><span style="color: #0000BB"><?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 />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"><br />"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></div>
</div>
</div>
</p>
</div>
<div class="refsect1 seealso" id="refsect1-function.session-cache-limiter-seealso">
<h3 class="title">See Also</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); ?>