Source of: /manual/en/function.session-id.php
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/include/shared-manual.inc';
$TOC = array();
$PARENTS = array();
include_once dirname(__FILE__) ."/toc/ref.session.inc";
$setup = array (
'home' =>
array (
0 => 'index.php',
1 => 'PHP Manual',
),
'head' =>
array (
0 => 'UTF-8',
1 => 'en',
),
'this' =>
array (
0 => 'function.session-id.php',
1 => 'session_id',
),
'up' =>
array (
0 => 'ref.session.php',
1 => 'Session Functions',
),
'prev' =>
array (
0 => 'function.session-get-cookie-params.php',
1 => 'session_get_cookie_params',
),
'next' =>
array (
0 => 'function.session-is-registered.php',
1 => 'session_is_registered',
),
);
$setup["toc"] = $TOC;
$setup["parents"] = $PARENTS;
manual_setup($setup);
manual_header();
?>
<div id="function.session-id" class="refentry">
<div class="refnamediv">
<h1 class="refname">session_id</h1>
<p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">session_id</span> — <span class="dc-title">Get and/or set the current session id</span></p>
</div>
<a name="function.session-id.description"></a><div class="refsect1 description">
<h3 class="title">Description</h3>
<div class="methodsynopsis dc-description">
<span class="type">string</span> <span class="methodname"><b>session_id</b></span>
([ <span class="methodparam"><span class="type">string</span> <tt class="parameter">$id</tt></span>
] )</div>
<p class="para rdfs-comment">
<b>session_id()</b> is used to get or set the session id for
the current session.
</p>
<p class="para">
The constant <b><tt class="constant">SID</tt></b> can also be used to
retrieve the current name and session id as a string suitable for
adding to URLs. See also <a href="ref.session.php" class="link">Session
handling</a>.
</p>
</div>
<a name="function.session-id.parameters"></a><div class="refsect1 parameters">
<h3 class="title">Parameters</h3>
<p class="para">
</p><dl>
<dt class="varlistentry">
<span class="term"><i><tt class="parameter">id</tt></i>
</span>
</dt><dd class="listitem">
<p class="para">
If <i><tt class="parameter">id</tt></i>
is specified, it will replace the current
session id. <b>session_id()</b> needs to be called before
<a href="function.session-start.php" class="function">session_start()</a> for that purpose. Depending on the
session handler, not all characters are allowed within the session id.
For example, the file session handler only allows characters in the
range <i>a-z A-Z 0-9 , (comma) and - (minus)</i>!
</p>
<blockquote><p><b class="note">Note</b>:
<span class="simpara">
When using session cookies, specifying an <i><tt class="parameter">id</tt></i>
for <b>session_id()</b> will always send a new cookie
when <a href="function.session-start.php" class="function">session_start()</a> is called, regardless if the
current session id is identical to the one being set.
</span>
</p></blockquote>
</dd>
</dl>
<p>
</p>
</div>
<a name="function.session-id.returnvalues"></a><div class="refsect1 returnvalues">
<h3 class="title">Return Values</h3>
<p class="para">
<b>session_id()</b> returns the session id for the current
session or the empty string (<i>""</i>) if there is no current
session (no current session id exists).
</p>
</div>
<a name="function.session-id.changelog"></a><div class="refsect1 changelog">
<h3 class="title">Changelog</h3>
<p class="para">
</p><table class="doctable informaltable">
<thead valign="middle">
<tr valign="middle">
<th>Version</th>
<th>Description</th>
</tr>
</thead>
<tbody valign="middle" class="tbody">
<tr valign="middle">
<td align="left">5.0.0</td>
<td align="left">
The <i>,</i> (comma) and <i>-</i> (minus)
characters are allowed in the file session handler.
</td>
</tr>
</tbody>
</table>
<p>
</p>
</div>
<a name="function.session-id.seealso"></a><div class="refsect1 seealso">
<h3 class="title">See Also</h3>
<p class="para">
</p><ul class="simplelist">
<li class="member"><a href="function.session-regenerate-id.php" class="function" rel="rdfs-seeAlso">session_regenerate_id()</a> - Update the current session id with a newly generated one</li>
<li class="member"><a href="function.session-start.php" class="function" rel="rdfs-seeAlso">session_start()</a> - Initialize session data</li>
<li class="member"><a href="function.session-set-save-handler.php" class="function" rel="rdfs-seeAlso">session_set_save_handler()</a> - Sets user-level session storage functions</li>
<li class="member">
<a href="session.configuration.php#ini.session.save-handler" class="link">session.save_handler</a>
</li>
</ul><p>
</p>
</div>
</div><?php manual_footer(); ?>