📄 session.configuration.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Runtime Configuration</title> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="session.installation.html">Installation</a></div> <div class="next" style="text-align: right; float: right;"><a href="session.resources.html">Resource Types</a></div> <div class="up"><a href="session.setup.html">Installing/Configuring</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="session.configuration" class="section"> <h2 class="title">Runtime Configuration</h2> <p class="simpara">The behaviour of these functions is affected by settings in <var class="filename">php.ini</var>.</p> <p class="para"> <table border="5"> <caption><b>Session configuration options</b></caption> <colgroup> <thead valign="middle"> <tr valign="middle"> <th colspan="1">Name</th> <th colspan="1">Default</th> <th colspan="1">Changeable</th> <th colspan="1">Changelog</th> </tr> </thead> <tbody valign="middle" class="tbody"> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.save_path</td> <td colspan="1" rowspan="1" align="left">""</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.name</td> <td colspan="1" rowspan="1" align="left">"PHPSESSID"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.save_handler</td> <td colspan="1" rowspan="1" align="left">"files"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.auto_start</td> <td colspan="1" rowspan="1" align="left">"0"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.gc_probability</td> <td colspan="1" rowspan="1" align="left">"1"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.gc_divisor</td> <td colspan="1" rowspan="1" align="left">"100"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td colspan="1" rowspan="1" align="left">Available since PHP 4.3.2.</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.gc_maxlifetime</td> <td colspan="1" rowspan="1" align="left">"1440"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.serialize_handler</td> <td colspan="1" rowspan="1" align="left">"php"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.cookie_lifetime</td> <td colspan="1" rowspan="1" align="left">"0"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.cookie_path</td> <td colspan="1" rowspan="1" align="left">"/"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.cookie_domain</td> <td colspan="1" rowspan="1" align="left">""</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.cookie_secure</td> <td colspan="1" rowspan="1" align="left">""</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td colspan="1" rowspan="1" align="left">Available since PHP 4.0.4.</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.cookie_httponly</td> <td colspan="1" rowspan="1" align="left">""</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td colspan="1" rowspan="1" align="left">Available since PHP 5.2.0.</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.use_cookies</td> <td colspan="1" rowspan="1" align="left">"1"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.use_only_cookies</td> <td colspan="1" rowspan="1" align="left">"1"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td colspan="1" rowspan="1" align="left">Available since PHP 4.3.0.</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.referer_check</td> <td colspan="1" rowspan="1" align="left">""</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.entropy_file</td> <td colspan="1" rowspan="1" align="left">""</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.entropy_length</td> <td colspan="1" rowspan="1" align="left">"0"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.cache_limiter</td> <td colspan="1" rowspan="1" align="left">"nocache"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.cache_expire</td> <td colspan="1" rowspan="1" align="left">"180"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td class="empty"> </td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.use_trans_sid</td> <td colspan="1" rowspan="1" align="left">"0"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL in PHP <= 4.2.3. PHP_INI_PERDIR in PHP < 5. Available since PHP 4.0.3.</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.bug_compat_42</td> <td colspan="1" rowspan="1" align="left">"1"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td colspan="1" rowspan="1" align="left">Available since PHP 4.3.0. Removed in PHP 6.0.0.</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.bug_compat_warn</td> <td colspan="1" rowspan="1" align="left">"1"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td colspan="1" rowspan="1" align="left">Available since PHP 4.3.0. Removed in PHP 6.0.0.</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.hash_function</td> <td colspan="1" rowspan="1" align="left">"0"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td colspan="1" rowspan="1" align="left">Available since PHP 5.0.0.</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">session.hash_bits_per_character</td> <td colspan="1" rowspan="1" align="left">"4"</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td colspan="1" rowspan="1" align="left">Available since PHP 5.0.0.</td> </tr> <tr valign="middle"> <td colspan="1" rowspan="1" align="left">url_rewriter.tags</td> <td colspan="1" rowspan="1" align="left">"a=href,area=href,frame=src,form=,fieldset="</td> <td colspan="1" rowspan="1" align="left">PHP_INI_ALL</td> <td colspan="1" rowspan="1" align="left">Available since PHP 4.0.4.</td> </tr> </tbody> </colgroup> </table> For further details and definitions of the PHP_INI_* constants, see the <a href="ini.html" class="xref">php.ini directives</a>. </p> <p class="para"> The session management system supports a number of configuration options which you can place in your <var class="filename">php.ini</var> file. We will give a short overview. <dl> <dt id="ini.session.save-handler"> <span class="term"> <i><tt class="parameter">session.save_handler</tt></i> <a href="language.types.string.html" class="type string">string</a> </span> <dd> <span class="simpara"> <i>session.save_handler</i> defines the name of the handler which is used for storing and retrieving data associated with a session. Defaults to <i>files</i>. Note that individual extensions may register their own <i>save_handler</i>s; registered handlers can be obtained on a per-installation basis by referring to <a href="function.phpinfo.html" class="function">phpinfo()</a>. See also <a href="function.session-set-save-handler.html" class="function">session_set_save_handler()</a>. </span> </dd> </dt> <dt id="ini.session.save-path"> <span class="term"> <i><tt class="parameter">session.save_path</tt></i> <a href="language.types.string.html" class="type string">string</a> </span> <dd> <span class="simpara"> <i>session.save_path</i> defines the argument which is passed to the save handler. If you choose the default files handler, this is the path where the files are created. See also <a href="function.session-save-path.html" class="function">session_save_path()</a>. </span> <p class="para"> There is an optional N argument to this directive that determines the number of directory levels your session files will be spread around in. For example, setting to <i>'5;/tmp'</i> may end up creating a session file and location like <i>/tmp/4/b/1/e/3/sess_4b1e384ad74619bd212e236e52a5a174If </i>. In order to use N you must create all of these directories before use. A small shell script exists in <var class="filename">ext/session</var> to do this, it's called <var class="filename">mod_files.sh</var>. Also note that if N is used and greater than 0 then automatic garbage collection will not be performed, see a copy of <var class="filename">php.ini</var> for further information. Also, if you use N, be sure to surround <i>session.save_path</i> in "quotes" because the separator (<i>;</i>) is also used for comments in <var class="filename">php.ini</var>. </p> <div class="warning"><b class="warning">Warning</b> <p class="para"> If you leave this set to a world-readable directory, such as <var class="filename">/tmp</var> (the default), other users on the server may be able to hijack sessions by getting the list of files in that directory. </p> </div> <blockquote><p><b class="note">Note</b>: <span class="simpara"> Prior to PHP 4.3.6, Windows users had to change this variable in order to use PHP's session functions. A valid path must be specified, e.g.: <var class="filename">c:/temp</var>. </span> </p></blockquote> </dd> </dt> <dt id="ini.session.name"> <span class="term"> <i><tt class="parameter">session.name</tt></i> <a href="language.types.string.html" class="type string">string</a> </span> <dd> <span class="simpara"> <i>session.name</i> specifies the name of the session which is used as cookie name. It should only contain alphanumeric characters. Defaults to <i>PHPSESSID</i>. See also <a href="function.session-name.html" class="function">session_name()</a>. </span> </dd> </dt> <dt id="ini.session.auto-start"> <span class="term"> <i><tt class="parameter">session.auto_start</tt></i> <a href="language.types.boolean.html" class="type boolean">boolean</a> </span> <dd> <span class="simpara"> <i>session.auto_start</i> specifies whether the session module starts a session automatically on request startup. Defaults to <i>0</i> (disabled). </span> </dd> </dt> <dt id="ini.session.serialize-handler"> <span class="term"> <i><tt class="parameter">session.serialize_handler</tt></i> <a href="language.types.string.html" class="type string">string</a> </span> <dd> <span class="simpara"> <i>session.serialize_handler</i> defines the name of the handler which is used to serialize/deserialize data. Currently, a PHP internal format (name <i>php</i> or <i>php_binary</i>) and WDDX are supported (name <i>wddx</i>). WDDX is only available, if PHP is compiled with <a href="ref.wddx.html" class="link">WDDX support</a>. Defaults to <i>php</i>. </span> </dd> </dt> <dt id="ini.session.gc-probability"> <span class="term"> <i><tt class="parameter">session.gc_probability</tt></i> <a href="language.types.integer.html" class="type integer">integer</a> </span> <dd> <span class="simpara"> <i>session.gc_probability</i> in conjunction with <i>session.gc_divisor</i> is used to manage probability that the gc (garbage collection) routine is started. Defaults to <i>1</i>. See <a href="session.configuration.html#ini.session.gc-divisor" class="link">session.gc_divisor</a> for details. </span> </dd> </dt> <dt id="ini.session.gc-divisor"> <span class="term"> <i><tt class="parameter">session.gc_divisor</tt></i> <a href="language.types.integer.html" class="type integer">integer</a> </span> <dd> <span class="simpara"> <i>session.gc_divisor</i> coupled with <i>session.gc_probability</i> defines the probability that the gc (garbage collection) process is started on every session initialization. The probability is calculated by using gc_probability/gc_divisor, e.g. 1/100 means there is a 1% chance that the GC process starts on each request. <i>session.gc_divisor</i> defaults to <i>100</i>. </span> </dd> </dt> <dt id="ini.session.gc-maxlifetime"> <span class="term"> <i><tt class="parameter">session.gc_maxlifetime</tt></i> <a href="language.types.integer.html" class="type integer">integer</a> </span> <dd> <span class="simpara"> <i>session.gc_maxlifetime</i> specifies the number of seconds after which data will be seen as 'garbage' and cleaned up. Garbage collection occurs during session start. </span> <blockquote><p><b class="note">Note</b>: If different scripts have different values of <i>session.gc_maxlifetime</i> but share the same place for storing the session data then the script with the minimum value will be cleaning the data. In this case, use this directive together with <a href="session.configuration.html#ini.session.save-path" class="link">session.save_path</a>. <br /> </p></blockquote> <blockquote><p><b class="note">Note</b>: <span class="simpara">If you are using the default file-based session handler, your filesystem must keep track of access times (atime). Windows FAT does not so you will have to come up with another way to handle garbage collecting your session if you are stuck with a FAT filesystem or any other filesystem where atime tracking is not available. Since PHP 4.2.3 it has used mtime (modified date) instead of atime. So, you won't have problems with filesystems where atime tracking is not available. </span> </p></blockquote> </dd> </dt>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -