-
Notifications
You must be signed in to change notification settings - Fork 101
/
book.xml
96 lines (92 loc) · 3.88 KB
/
book.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<!-- EN-Revision: ba6a83ca3558574695be5ef0a0e008e4e5f78ddb Maintainer: Szopen Xiao Status: ready -->
<!-- CREDITS: mowangjuanzi, Luffy -->
<book xml:id="book.session" xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink">
<?phpdoc extension-membership="bundled" ?>
<title>Session 处理</title>
<titleabbrev>Sessions</titleabbrev>
<!-- {{{ preface -->
<preface xml:id="intro.session">
&reftitle.intro;
<para>
会话支持在 PHP 中是在并发访问时由一个方法来保存某些数据。
</para>
<para>
一个访问者访问你的 web 网站将被分配一个唯一的 id,就是所谓的会话 id。
这个 id 可以存储在用户端的一个 cookie 中,也可以通过 URL 进行传递。
</para>
<para>
会话支持允许你将请求中的数据保存在超全局数组<varname>$_SESSION</varname>中。
当一个访问者访问你的网站,PHP 将自动检查(如果 <link linkend="ini.session.auto-start">session.auto_start</link>
被设置为 1)或者在你要求下检查(明确通过
<function>session_start</function>) 当前会话 id 是否是先前发送的请求创建。如果是这种情况,
那么先前保存的环境将被重建。
</para>
<caution>
<para>
如果你打开了 <link linkend="ini.session.auto-start">session.auto_start</link> 那么
将对象放入会话的唯一方法是使用 <link linkend="ini.auto-prepend-file">auto_prepend_file</link>
来加载定义这个对象的类,其中,在加载的定义的类时,你不得不使用 <function>serialize</function>
你得对象,并且事后 <function>unserialize</function> 它。
</para>
</caution>
<para>
<varname>$_SESSION</varname> (和所有已注册得变量) 将被 PHP 使用内置的序列化方法在请求完成时
进行序列化。序列化方法可以通过 <link linkend="ini.session.serialize-handler">session.serialize_handler</link>
这个 PHP 配置选项中来设置一个指定的方法。注册的变量未定义将被标记为未定义。在并发访问时,这些变量不会被会话模块
定义除非用户后来定义了它们。
</para>
<warning>
<para>
因为会话数据是被序列化的,<type>resource</type> 变量不能被存储在会话中。
</para>
<para>
序列化句柄 (<literal>php</literal>
和 <literal>php_binary</literal>) 会受到 register_globals 的限制。
而且,数字索引或者字符串索引包含的特殊字符(<literal>|</literal>
和 <literal>!</literal>) 不能被使用。使用这些字符将脚本执行关闭时的最后出现错误。
<literal>php_serialize</literal> 没有这样的限制。
</para>
</warning>
<note>
<para>
请注意当会话工作时,会话的记录并没有被创建
直到一个变量已经被添加一个新元素到 <varname>$_SESSION</varname> 全局数组中。
这点一直有效,无论是否使用 <function>session_start</function> 函数
来开始会话。
</para>
</note>
</preface>
<!-- }}} -->
&reference.session.setup;
&reference.session.constants;
&reference.session.examples;
&reference.session.upload-progress;
&reference.session.security;
&reference.session.reference;
&reference.session.sessionhandler;
&reference.session.sessionhandlerinterface;
&reference.session.sessionidinterface;
&reference.session.sessionupdatetimestamphandlerinterface;
</book>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->