📄 intro.session.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Introduction</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="book.session.html">Sessions</a></div> <div class="next" style="text-align: right; float: right;"><a href="session.setup.html">Installing/Configuring</a></div> <div class="up"><a href="book.session.html">Sessions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="intro.session" class="preface"> <h1 class="title">Introduction</h1> <p class="para"> Session support in PHP consists of a way to preserve certain data across subsequent accesses. This enables you to build more customized applications and increase the appeal of your web site. </p> <p class="para"> A visitor accessing your web site is assigned a unique id, the so-called session id. This is either stored in a cookie on the user side or is propagated in the URL. </p> <p class="para"> The session support allows you to register arbitrary numbers of variables to be preserved across requests. When a visitor accesses your site, PHP will check automatically (if <a href="session.configuration.html#ini.session.auto-start" class="link">session.auto_start</a> is set to 1) or on your request (explicitly through <a href="function.session-start.html" class="function">session_start()</a> or implicitly through <a href="function.session-register.html" class="function">session_register()</a>) whether a specific session id has been sent with the request. If this is the case, the prior saved environment is recreated. </p> <div class="caution"><b class="caution">Caution</b> <p class="para"> If you do turn on <a href="session.configuration.html#ini.session.auto-start" class="link"> session.auto_start</a> then you cannot put objects into your sessions since the class definition has to be loaded before starting the session in order to recreate the objects in your session. </p> </div> <p class="para"> All registered variables are serialized after the request finishes. Registered variables which are undefined are marked as being not defined. On subsequent accesses, these are not defined by the session module unless the user defines them later. </p> <div class="warning"><b class="warning">Warning</b> <p class="para"> Some types of data can not be serialized thus stored in sessions. It includes <a href="language.types.resource.html" class="type resource">resource</a> variables or objects with circular references (i.e. objects which passes a reference to itself to another object). </p> </div> <blockquote><p><b class="note">Note</b>: Session handling was added in PHP 4.0.0. <br /> </p></blockquote> <blockquote><p><b class="note">Note</b>: Please note when working with sessions that a record of a session is not created until a variable has been registered using the <a href="function.session-register.html" class="function">session_register()</a> function or by adding a new key to the <var class="varname"><a href="reserved.variables.session.html" class="classname">$_SESSION</a></var> superglobal array. This holds true regardless of if a session has been started using the <a href="function.session-start.html" class="function">session_start()</a> function. <br /> </p></blockquote> </div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="book.session.html">Sessions</a></div> <div class="next" style="text-align: right; float: right;"><a href="session.setup.html">Installing/Configuring</a></div> <div class="up"><a href="book.session.html">Sessions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div></body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -