mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 08:58:56 +00:00
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:
parent
b9af14d4e3
commit
d6fdce28a1
1 changed files with 2 additions and 83 deletions
|
@ -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 <?php echo $count; ?> times.<p>
|
||||
|
||||
<php?
|
||||
# the <?php echo SID;?> is necessary to preserve the session id
|
||||
# the <?=SID?> is necessary to preserve the session id
|
||||
# in the case that the user has disabled cookies
|
||||
?>
|
||||
|
||||
To continue, <A HREF="nextpage.php?<?php echo SID;?>">click here</A>
|
||||
To continue, <A HREF="nextpage.php?<?=SID?>">click here</A>
|
||||
</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">
|
||||
<?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++;
|
||||
|
||||
?>
|
||||
</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><?=SID?></literal> is not necessary, if
|
||||
<literal>--enable-trans-sid</literal> was used to compile PHP.
|
||||
>>>>>>> 1.23
|
||||
</para>
|
||||
<para>
|
||||
<<<<<<< session.xml
|
||||
The <literal><?php echo SID;?></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.
|
||||
|
|
Loading…
Reference in a new issue