mirror of
https://github.com/fofolee/uTools-Manuals.git
synced 2025-06-18 22:06:57 +08:00
185 lines
6.2 KiB
HTML
185 lines
6.2 KiB
HTML
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||
<html>
|
||
<head>
|
||
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
|
||
<title>设置会话 cookie 参数</title>
|
||
</head>
|
||
<body class="docs"><div id="layout">
|
||
<div id="layout-content"><div id="function.session-set-cookie-params" class="refentry">
|
||
<div class="refnamediv">
|
||
<h1 class="refname">session_set_cookie_params</h1>
|
||
<p class="verinfo">(PHP 4, PHP 5, PHP 7)</p><p class="refpurpose"><span class="refname">session_set_cookie_params</span> — <span class="dc-title">设置会话 cookie 参数</span></p>
|
||
|
||
</div>
|
||
|
||
<div class="refsect1 description" id="refsect1-function.session-set-cookie-params-description">
|
||
<h3 class="title">说明</h3>
|
||
<div class="methodsynopsis dc-description">
|
||
<span class="methodname"><strong>session_set_cookie_params</strong></span>
|
||
( <span class="methodparam"><span class="type">int</span> <code class="parameter">$lifetime</code></span>
|
||
[, <span class="methodparam"><span class="type">string</span> <code class="parameter">$path</code></span>
|
||
[, <span class="methodparam"><span class="type">string</span> <code class="parameter">$domain</code></span>
|
||
[, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$secure</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
|
||
[, <span class="methodparam"><span class="type">bool</span> <code class="parameter">$httponly</code><span class="initializer"> = <strong><code>FALSE</code></strong></span></span>
|
||
]]]] ) : <span class="type">bool</span></div>
|
||
|
||
<p class="para rdfs-comment">
|
||
Cookie 参数可以在 <var class="filename">php.ini</var> 文件中定义,本函数仅在当前脚本执行过程中有效。
|
||
因此,如果要通过函数修改 cookie 参数,需要对每个请求都要
|
||
在调用 <span class="function"><a href="session_start.html" class="function">session_start()</a></span> 函数之前调用
|
||
<span class="function"><strong>session_set_cookie_params()</strong></span> 函数。
|
||
</p>
|
||
<p class="para">
|
||
本函数会修改运行期 ini 设置值,
|
||
可以通过 <span class="function"><a href="ini_get.html" class="function">ini_get()</a></span> 函数获取这些值。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 parameters" id="refsect1-function.session-set-cookie-params-parameters">
|
||
<h3 class="title">参数</h3>
|
||
<p class="para">
|
||
<dl>
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">lifetime</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
Cookie 的 <a href="session.configuration.html#ini.session.cookie-lifetime" class="link">生命周期</a>,以秒为单位。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">path</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
此 cookie 的有效 <a href="session.configuration.html#ini.session.cookie-path" class="link">路径</a>。 on the domain where
|
||
设置为“/”表示对于本域上所有的路径此 cookie 都可用。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">domain</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
Cookie 的作用 <a href="session.configuration.html#ini.session.cookie-domain" class="link">域</a>。
|
||
例如:“www.php.net”。
|
||
如果要让 cookie 在所有的子域中都可用,此参数必须以点(.)开头,例如:“.php.net”。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">secure</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
设置为 <strong><code>TRUE</code></strong> 表示 cookie 仅在使用
|
||
<a href="session.configuration.html#ini.session.cookie-secure" class="link">安全</a> 链接时可用。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
|
||
<dt>
|
||
<code class="parameter">httponly</code></dt>
|
||
|
||
<dd>
|
||
|
||
<p class="para">
|
||
设置为 <strong><code>TRUE</code></strong> 表示 PHP 发送 cookie 的时候会使用
|
||
<a href="session.configuration.html#ini.session.cookie-httponly" class="link">httponly</a>
|
||
标记。
|
||
</p>
|
||
</dd>
|
||
|
||
|
||
</dl>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 returnvalues" id="refsect1-function.session-set-cookie-params-returnvalues">
|
||
<h3 class="title">返回值</h3>
|
||
<p class="para">
|
||
成功时返回 <strong><code>TRUE</code></strong>, 或者在失败时返回 <strong><code>FALSE</code></strong>。
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 changelog" id="refsect1-function.session-set-cookie-params-changelog">
|
||
<h3 class="title">更新日志</h3>
|
||
<p class="para">
|
||
<table class="doctable informaltable">
|
||
|
||
<thead>
|
||
<tr>
|
||
<th>版本</th>
|
||
<th>说明</th>
|
||
</tr>
|
||
|
||
</thead>
|
||
|
||
<tbody class="tbody">
|
||
<tr>
|
||
<td>7.2.0</td>
|
||
<td>
|
||
成功时返回 <strong><code>TRUE</code></strong>, 或者在失败时返回 <strong><code>FALSE</code></strong>。 之前版本中是返回 <span class="type"><span class="type void">void</span></span> 的。
|
||
</td>
|
||
</tr>
|
||
|
||
<tr>
|
||
<td>5.2.0</td>
|
||
<td>
|
||
加入 <code class="parameter">httponly</code> 参数。
|
||
</td>
|
||
</tr>
|
||
|
||
</tbody>
|
||
|
||
</table>
|
||
|
||
</p>
|
||
</div>
|
||
|
||
|
||
<div class="refsect1 seealso" id="refsect1-function.session-set-cookie-params-seealso">
|
||
<h3 class="title">参见</h3>
|
||
<p class="para">
|
||
<ul class="simplelist">
|
||
<li class="member">
|
||
<a href="session.configuration.html#ini.session.cookie-lifetime" class="link">session.cookie_lifetime</a>
|
||
</li>
|
||
<li class="member">
|
||
<a href="session.configuration.html#ini.session.cookie-path" class="link">session.cookie_path</a>
|
||
</li>
|
||
<li class="member">
|
||
<a href="session.configuration.html#ini.session.cookie-domain" class="link">session.cookie_domain</a>
|
||
</li>
|
||
<li class="member">
|
||
<a href="session.configuration.html#ini.session.cookie-secure" class="link">session.cookie_secure</a>
|
||
</li>
|
||
<li class="member">
|
||
<a href="session.configuration.html#ini.session.cookie-httponly" class="link">session.cookie_httponly</a>
|
||
</li>
|
||
<li class="member"><span class="function"><a href="session_get_cookie_params.html" class="function" rel="rdfs-seeAlso">session_get_cookie_params()</a> - 获取会话 cookie 参数</span></li>
|
||
</ul>
|
||
</p>
|
||
</div>
|
||
|
||
|
||
</div></div></div></body></html> |