cvs: /phpdoc/functions session.sgml
| From: | Egon Schmid | Date: | Thu, 21 Oct 1999 17:27:20 +0000 |
| Subject: | cvs: /phpdoc/functions session.sgml | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-11815@lists.php.net to get a copy of this message | ||
eschmid Thu Oct 21 13:27:20 1999 EDT
Modified files:
/phpdoc/functions session.sgml
Log:
Sascha did you mean that?
Index: phpdoc/functions/session.sgml
diff -u phpdoc/functions/session.sgml:1.8 phpdoc/functions/session.sgml:1.9
--- phpdoc/functions/session.sgml:1.8 Wed Oct 20 18:41:42 1999
+++ phpdoc/functions/session.sgml Thu Oct 21 13:27:18 1999
@@ -77,6 +77,76 @@
</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>
+ <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) {
+ echo "write ($key, $val)\n";
+ 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>
+ </para>
+
+ <para>
The <literal><?=SID?></literal> is not necessary, if
<literal>--enable-trans-sid</literal> was used to compile PHP.</para>