reverting my last (accidential) commit

git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@46306 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
Hartmut Holzgraefe 2001-05-01 18:25:08 +00:00
parent b9af14d4e3
commit d6fdce28a1

View file

@ -136,8 +136,6 @@ $count++;
<para>
The following example demonstrates how to register a variable, and
how to link correctly to another page using SID.
</para>
<para>
<example>
<title>Counting the number of hits of a single user</title>
<programlisting role="php">
@ -149,94 +147,17 @@ $count++;
Hello visitor, you have seen this page &lt;?php echo $count; ?&gt; times.&lt;p&gt;
&lt;php?
# the &lt;?php echo SID;?&gt; is necessary to preserve the session id
# the &lt;?=SID?&gt; is necessary to preserve the session id
# in the case that the user has disabled cookies
?&gt;
To continue, &lt;A HREF="nextpage.php?&lt;?php echo SID;?&gt;"&gt;click here&lt;/A&gt;
To continue, &lt;A HREF="nextpage.php?&lt;?=SID?&gt;"&gt;click here&lt;/A&gt;
</programlisting>
</example>
</para>
<para>
To implement database storage you need PHP code and a user level
function <function>session_set_save_handler</function>. You would
have to extend the following functions to cover MySQL or another
database.
</para>
<para>
<<<<<<< session.xml
<example>
<title>
Usage of <function>session_set_save_handler</function>
</title>
<programlisting role="php">
&lt;?php
function open ($save_path, $session_name) {
echo "open ($save_path, $session_name)\n";
return true;
}
function close() {
echo "close\n";
return true;
}
function read ($key) {
<<<<<<< session.xml
echo "read ($key, $val)\n";
=======
echo "read ($key)\n";
>>>>>>> 1.19
return "foo|i:1;";
}
function write ($key, $val) {
echo "write ($key, $val)\n";
return true;
}
function destroy ($key) {
return true;
}
function gc ($maxlifetime) {
return true;
}
session_set_save_handler ("open", "close", "read", "write", "destroy", "gc");
session_start();
$foo++;
?&gt;
</programlisting>
</example>
</para>
<para>
Will produce this results:
</para>
<para>
<programlisting>
$ ./php save_handler.php
Content-Type: text/html
Set-cookie: PHPSESSID=f08b925af0ecb52bdd2de97d95cdbe6b
open (/tmp, PHPSESSID)
read (f08b925af0ecb52bdd2de97d95cdbe6b)
write (f08b925af0ecb52bdd2de97d95cdbe6b, foo|i:2;)
close
</programlisting>
=======
The <literal>&lt;?=SID?&gt;</literal> is not necessary, if
<literal>--enable-trans-sid</literal> was used to compile PHP.
>>>>>>> 1.23
</para>
<para>
<<<<<<< session.xml
The <literal>&lt;?php echo SID;?&gt;</literal> is not necessary, if
<literal>--enable-trans-sid</literal> was used to compile PHP.
</para>
<note>
<para>
@ -246,13 +167,11 @@ close
</para>
</note>
<para>
=======
To implement database storage, or any other storage method, you
will need to use <function>session_set_save_handler</function> to
create a set of user-level storage functions.
</para>
<para>
>>>>>>> 1.23
The session management system supports a number of configuration
options which you can place in your php.ini file. We will give a
short overview.