📄 function.session-name.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Get and/or set the current session name</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="function.session-module-name.html">session_module_name</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.session-regenerate-id.html">session_regenerate_id</a></div> <div class="up"><a href="ref.session.html">Session Functions</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div id="function.session-name" class="refentry"> <div class="refnamediv"> <h1 class="refname">session_name</h1> <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">session_name</span> — <span class="dc-title">Get and/or set the current session name</span></p> </div> <div class="refsect1 description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="type">string</span> <span class="methodname"><b><b>session_name</b></b></span> ([ <span class="methodparam"><span class="type">string</span> <tt class="parameter">$name</tt></span> ] )</div> <p class="para rdfs-comment"> <b>session_name()</b> returns the name of the current session. </p> <p class="para"> The session name is reset to the default value stored in <i>session.name</i> at request startup time. Thus, you need to call <b>session_name()</b> for every request (and before <a href="function.session-start.html" class="function">session_start()</a> or <a href="function.session-register.html" class="function">session_register()</a> are called). </p> </div> <div class="refsect1 parameters"> <h3 class="title">Parameters</h3> <p class="para"> <dl> <dt> <span class="term"><i><tt class="parameter">name</tt></i></span> <dd> <p class="para"> The session name references the session id in cookies and URLs. It should contain only alphanumeric characters; it should be short and descriptive (i.e. for users with enabled cookie warnings). If <i><tt class="parameter">name</tt></i> is specified, the name of the current session is changed to its value. </p> <p class="para"> <div class="warning"><b class="warning">Warning</b> <p class="para"> The session name can't consist of digits only, at least one letter must be present. Otherwise a new session id is generated every time. </p> </div> </p> </dd> </dt> </dl> </p> </div> <div class="refsect1 returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> Returns the name of the current session. </p> </div> <div class="refsect1 examples"> <h3 class="title">Examples</h3> <p class="para"> <div class="example"> <p><b>Example #1 <b>session_name()</b> example</b></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 session name to WebsiteID */<br /><br /></span><span style="color: #0000BB">$previous_name </span><span style="color: #007700">= </span><span style="color: #0000BB">session_name</span><span style="color: #007700">(</span><span style="color: #DD0000">"WebsiteID"</span><span style="color: #007700">);<br /><br />echo </span><span style="color: #DD0000">"The previous session name was $previous_name<br />"</span><span style="color: #007700">;<br /></span><span style="color: #0000BB">?></span></span></code></div> </div> </div> </p> </div> <div class="refsect1 seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> The <a href="session.configuration.html#ini.session.name" class="link">session.name</a> configuration directive </li> </ul> </p> </div></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="function.session-module-name.html">session_module_name</a></div> <div class="next" style="text-align: right; float: right;"><a href="function.session-regenerate-id.html">session_regenerate_id</a></div> <div class="up"><a href="ref.session.html">Session Functions</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 + -