cvs: peardoc /en/package/http http-session.xml /en/package/http/http-session database.xml intro.xml

From: Date: Sat, 04 Nov 2006 13:30:25 +0000
Subject: cvs: peardoc /en/package/http http-session.xml /en/package/http/http-session database.xml intro.xml
Groups: php.pear.doc 
Request: Send a blank email to pear-doc+get-8709@lists.php.net to get a copy of this message
troehr Sat Nov 4 13:30:25 2006 UTC Added files: /peardoc/en/package/http http-session.xml /peardoc/en/package/http/http-session database.xml intro.xml Log: Initial checkin http://cvs.php.net/viewvc.cgi/peardoc/en/package/http/http-session.xml?view=markup&rev=1.1 Index: peardoc/en/package/http/http-session.xml +++ peardoc/en/package/http/http-session.xml <!-- $Revision: 1.1 $ --> <sect1 id="package.http.http-session"> <title>HTTP_Session</title> <para> The package provides an Object-oriented interface to the session_* family functions. It provides extra features such as database storage for session data using the DB, MDB and MDB2 package. It introduces new methods like isNew(), useCookies(), setExpire(), setIdle(), isExpired(), isIdled() and others. </para> &package.http.http-session.intro; &package.http.http-session.database; </sect1> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/peardoc/en/package/http/http-session/database.xml?view=markup&rev=1.1 Index: peardoc/en/package/http/http-session/database.xml +++ peardoc/en/package/http/http-session/database.xml <!-- $Revision: 1.1 $ --> <refentry id="package.http.http-session.database"> <refnamediv> <refname>Database container</refname> <refpurpose> Store session data in a database with <classname>HTTP_Session</classname> </refpurpose> </refnamediv> <refsect1 id="package.http.http-session.database.overview"> <title>Overview</title> <para> <classname>HTTP_Session</classname> lets you store the session data in a database making use of the DB, MDB and MDB2 packages. </para> </refsect1> <refsect1 id="package.http.http-session.database.examples"> <title>Example</title> <example> <title>Using MDB2 to store session data in a database</title> <programlisting role="php"> /* create the following table in your database CREATE TABLE sessiondata ( id varchar(32) NOT NULL, expiry int(10), data text, PRIMARY KEY (id) ); */ require_once 'HTTP/Session.php'; HTTP_Session::useTransSID(false); HTTP_Session::useCookies(false); // enter your DSN HTTP_Session::setContainer('MDB2', array('dsn' => 'mysql://root:password@localhost/database', 'table' => 'sessiondata')); /* // using an existing MDB2 connection HTTP_Session::setContainer('MDB2', array('dsn' => &amp;$db, 'table' => 'sessiondata')); */ HTTP_Session::start('s'); HTTP_Session::setExpire(time() + 60); // set expire to 60 seconds HTTP_Session::setIdle(time() + 5); // set idle to 5 seconds if (HTTP_Session::isExpired()) { //HTTP_Session::replicate('sessiondata_backup'); // Replicate data of current session to specified table HTTP_Session::destroy(); } if (HTTP_Session::isIdle()) { //HTTP_Session::replicate('sessiondata_backup'); // Replicate data of current session to specified table HTTP_Session::destroy(); } HTTP_Session::updateIdle(); </programlisting> </example> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 --> http://cvs.php.net/viewvc.cgi/peardoc/en/package/http/http-session/intro.xml?view=markup&rev=1.1 Index: peardoc/en/package/http/http-session/intro.xml +++ peardoc/en/package/http/http-session/intro.xml <!-- $Revision: 1.1 $ --> <refentry id="package.http.http-session.intro"> <refnamediv> <refname>Introduction</refname> <refpurpose> Introduction to <classname>HTTP_Session</classname> </refpurpose> </refnamediv> <refsect1 id="package.http.http-session.intro.overview"> <title>Overview</title> <para> This package provides access to session-state values as well as session-level settings and lifetime management methods. Based on the standart <acronym>PHP</acronym> session handling mechanism it provides more advanced features such as database containers, idle and expire timeouts, etc. </para> </refsect1> <refsect1 id="package.http.http-session.intro.examples"> <title>A few examples</title> <example> <title>Setting some options and detection of a new session</title> <programlisting role="php"> HTTP_Session::setCookieless(false); HTTP_Session::start('MySessionID'); HTTP_Session::set('variable', 'Tet string'); if (HTTP_Session::isNew()) { echo('new session was created with the current request'); $visitors++; // Increase visitors count } // after successful login use: HTTP_Session::regenerateId(); </programlisting> </example> <example> <title>Setting timeouts</title> <programlisting role="php"> HTTP_Session::start(); HTTP_Session::setExpire(time() + 60 * 60); // expires in one hour HTTP_Session::setIdle(time() + 10 * 60); // idles in ten minutes // expired if (HTTP_Session::isExpired()) { echo('Your session is expired!'); HTTP_Session::destroy(); } // idled if (HTTP_Session::isIdle()) { echo('You've been idle for too long!'); HTTP_Session::destroy(); } HTTP_Session::updateIdle(); </programlisting> </example> </refsect1> </refentry> <!-- Keep this comment at the end of the file Local variables: mode: sgml sgml-omittag:t sgml-shorttag:t sgml-minimize-attributes:nil sgml-always-quote-attributes:t sgml-indent-step:1 sgml-indent-data:t sgml-parent-document:nil sgml-default-dtd-file:"../../../../manual.ced" sgml-exposed-tags:nil sgml-local-catalogs:nil sgml-local-ecat-files:nil End: vim600: syn=xml fen fdm=syntax fdl=2 si vim: et tw=78 syn=sgml vi: ts=1 sw=1 -->

« previous php.pear.doc (#8709) next »