cvs: peardoc /en/package/http http-session2.xml /en/package/http/http-session2 cookies.xml database.xml intro.xml
[email protected] ("Till Klampaeckel")
| Newsgroups | php.pear.doc |
|---|---|
| Message-ID | <cvstill1197740511@cvsserver> |
till Sat Dec 15 17:41:51 2007 UTC
Added files:
/peardoc/en/package/http http-session2.xml
/peardoc/en/package/http/http-session2 cookies.xml database.xml
intro.xml
Log:
* initial checkin for http_session2 docs (adapter from http_session/troehr)
till-20071215174151.txt
(text/plain, 8.2 KB)
http://cvs.php.net/viewvc.cgi/peardoc/en/package/http/http-session2.xml?view=markup&rev=1.1
Index: peardoc/en/package/http/http-session2.xml
+++ peardoc/en/package/http/http-session2.xml
<!-- $Revision: 1.1 $ -->
<sect1 id="package.http.http-session2">
<title>HTTP_Session2</title>
<para>
The HTTP_Session2 package provides an Object-oriented interface to the session_*
family functions. It's a PHP5 port of the <classname>HTTP_Session</classname>
package.
</para>
<para>
HTTP_Session2 provides extra features such as database storage for session data
using the <classname>DB</classname> and <classname>MDB2</classname> package. It
also introduces new methods, such as isNew(), useCookies(), setExpire(), setIdle(),
isExpired(), isIdled() and others.
</para>
&package.http.http-session2.intro;
&package.http.http-session2.database;
&package.http.http-session2.cookies;
</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-session2/cookies.xml?view=markup&rev=1.1
Index: peardoc/en/package/http/http-session2/cookies.xml
+++ peardoc/en/package/http/http-session2/cookies.xml
<!-- $Revision: 1.1 $ -->
<refentry id="package.http.http-session2.cookies">
<refnamediv>
<refname>Making a session persistant</refname>
<refpurpose>
This example illustrates how to make a session persist over multiple browser
sessions using a so called "session cookie".
</refpurpose>
</refnamediv>
<refsect1 id="package.http.http-session2.cookies.intro">
<title>Overview</title>
<para>
When you enable <classname>HTTP_Session2</classname> lets you store the session
data in a database making use of the <classname>DB</classname> and
<classname>MDB2</classname> packages.
</para>
</refsect1>
<refsect1 id="package.http.http-session2.cookies.examples">
<title>Example</title>
<example>
<title>Using MDB2 to store session data in a database</title>
<programlisting role="php">
require_once 'HTTP/Session2.php';
/**
* set cookie params
*/
session_set_cookie_params(60*60*24, // expire in 24 hours
'/', // path
'.example.org', // domain
false, // "secure only"
true); // only over http
HTTP_Session2::useCookies(true);
HTTP_Session2::start('s');
HTTP_Session2::setExpire(time() + 60*60*24); // set expire in 24 hours
HTTP_Session2::setIdle(time() + 60*60); // set idle to 1 hour
if (HTTP_Session2::isExpired()) {
HTTP_Session2::destroy();
}
if (HTTP_Session2::isIdle()) {
HTTP_Session2::destroy();
}
HTTP_Session2::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-session2/database.xml?view=markup&rev=1.1
Index: peardoc/en/package/http/http-session2/database.xml
+++ peardoc/en/package/http/http-session2/database.xml
<!-- $Revision: 1.1 $ -->
<refentry id="package.http.http-session2.database">
<refnamediv>
<refname>Using a database container</refname>
<refpurpose>
How to store session data in a database with <classname>HTTP_Session2</classname>
</refpurpose>
</refnamediv>
<refsect1 id="package.http.http-session2.database.overview">
<title>Overview</title>
<para>
<classname>HTTP_Session</classname> lets you store the session data in a database
making use of the <classname>DB</classname> and <classname>MDB2</classname>
packages.
</para>
</refsect1>
<refsect1 id="package.http.http-session2.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/Session2.php';
HTTP_Session2::useTransSID(false);
HTTP_Session2::useCookies(false);
// enter your DSN
HTTP_Session2::setContainer('MDB2',
array('dsn' => 'mysql://root:password@localhost/database',
'table' => 'sessiondata'));
/*
// using an existing MDB2 connection
HTTP_Session2::setContainer('MDB2',
array('dsn' => &$db, 'table' => 'sessiondata'));
*/
HTTP_Session2::start('s');
HTTP_Session2::setExpire(time() + 60); // set expire to 60 seconds
HTTP_Session2::setIdle(time() + 5); // set idle to 5 seconds
if (HTTP_Session2::isExpired()) {
HTTP_Session2::destroy();
}
if (HTTP_Session2::isIdle()) {
HTTP_Session2::destroy();
}
HTTP_Session2::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-session2/intro.xml?view=markup&rev=1.1
Index: peardoc/en/package/http/http-session2/intro.xml
+++ peardoc/en/package/http/http-session2/intro.xml
<!-- $Revision: 1.1 $ -->
<refentry id="package.http.http-session2.intro">
<refnamediv>
<refname>Introduction</refname>
<refpurpose>
An introduction to <classname>HTTP_Session2</classname>
</refpurpose>
</refnamediv>
<refsect1 id="package.http.http-session2.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-session2.intro.examples">
<title>A few examples</title>
<example>
<title>Setting some options and detection of a new session</title>
<programlisting role="php">
HTTP_Session2::useCookies(false);
HTTP_Session2::start('MySessionID');
HTTP_Session2::set('variable', 'The string');
if (HTTP_Session2::isNew()) {
echo('new session was created with the current request');
$visitors++; // Increase visitors count
}
</programlisting>
</example>
<example>
<title>Setting timeouts</title>
<programlisting role="php">
HTTP_Session2::start();
HTTP_Session2::setExpire(time() + 60 * 60); // expires in one hour
HTTP_Session2::setIdle(time() + 10 * 60); // idles in ten minutes
// expired
if (HTTP_Session2::isExpired()) {
echo('Your session is expired!');
HTTP_Session2::destroy();
}
// idled
if (HTTP_Session2::isIdle()) {
echo 'You've been idle for too long!';
HTTP_Session2::destroy();
}
HTTP_Session2::updateIdle();
</programlisting>
</example>
<para>
For a more comprehensive example of persistant sessions, check the cookie section.
</para>
</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
-->