<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <title>Write session data</title> </head> <body><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sessionhandlerinterface.read.html">SessionHandlerInterface::read</a></div> <div class="next" style="text-align: right; float: right;"><a href="book.session-pgsql.html">Session PgSQL</a></div> <div class="up"><a href="class.sessionhandlerinterface.html">SessionHandlerInterface</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div><hr /><div id="sessionhandlerinterface.write" class="refentry"> <div class="refnamediv"> <h1 class="refname">SessionHandlerInterface::write</h1> <p class="verinfo">(PHP 5 >= 5.4.0)</p><p class="refpurpose"><span class="refname">SessionHandlerInterface::write</span> — <span class="dc-title">Write session data</span></p> </div> <div class="refsect1 description" id="refsect1-sessionhandlerinterface.write-description"> <h3 class="title">Description</h3> <div class="methodsynopsis dc-description"> <span class="modifier">abstract</span> <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>SessionHandlerInterface::write</strong></span> ( <span class="methodparam"><span class="type">string</span> <code class="parameter">$session_id</code></span> , <span class="methodparam"><span class="type">string</span> <code class="parameter">$session_data</code></span> )</div> <p class="para rdfs-comment"> Writes the session data to the session storage. Called by <span class="function"><a href="function.session-write-close.html" class="function">session_write_close()</a></span>, when <span class="function"><a href="function.session-register-shutdown.html" class="function">session_register_shutdown()</a></span> fails, or during a normal shutdown. Note: <span class="function"><a href="sessionhandlerinterface.close.html" class="function">SessionHandlerInterface::close()</a></span> is called immediately after this function. </p> <p class="para"> PHP will call this method when the session is ready to be saved and closed. It encodes the session data from the <var class="varname"><var class="varname"><a href="reserved.variables.session.html" class="classname">$_SESSION</a></var></var> superglobal to a serialized string and passes this along with the session ID to this method for storage. The serialization method used is specified in the <a href="session.configuration.html#ini.session.serialize-handler" class="link">session.serialize_handler</a> setting. </p> <p class="para"> Note this method is normally called by PHP after the output buffers have been closed unless explicitly called by <span class="function"><a href="function.session-write-close.html" class="function">session_write_close()</a></span> </p> </div> <div class="refsect1 parameters" id="refsect1-sessionhandlerinterface.write-parameters"> <h3 class="title">Parameters</h3> <dl> <dt> <span class="term"><em><code class="parameter">session_id</code></em></span> <dd> <p class="para"> The session id. </p> </dd> </dt> <dt> <span class="term"><em><code class="parameter">session_data</code></em></span> <dd> <p class="para"> The encoded session data. This data is the result of the PHP internally encoding the <var class="varname"><var class="varname"><a href="reserved.variables.session.html" class="classname">$_SESSION</a></var></var> superglobal to a serialized string and passing it as this parameter. Please note sessions use an alternative serialization method. </p> </dd> </dt> </dl> </div> <div class="refsect1 returnvalues" id="refsect1-sessionhandlerinterface.write-returnvalues"> <h3 class="title">Return Values</h3> <p class="para"> The return value (usually <strong><code>TRUE</code></strong> on success, <strong><code>FALSE</code></strong> on failure). Note this value is returned internally to PHP for processing. </p> </div> <div class="refsect1 seealso" id="refsect1-sessionhandlerinterface.write-seealso"> <h3 class="title">See Also</h3> <p class="para"> <ul class="simplelist"> <li class="member"> The <a href="session.configuration.html#ini.session.serialize-handler" class="link">session.serialize_handler</a> configuration directive. </li> </ul> </p> </div> </div><hr /><div class="manualnavbar" style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="sessionhandlerinterface.read.html">SessionHandlerInterface::read</a></div> <div class="next" style="text-align: right; float: right;"><a href="book.session-pgsql.html">Session PgSQL</a></div> <div class="up"><a href="class.sessionhandlerinterface.html">SessionHandlerInterface</a></div> <div class="home"><a href="index.html">PHP Manual</a></div> </div></body></html>