HTML-EP
view release on metacpan or search on metacpan
lib/HTML/EP/Session.pm view on Meta::CPAN
SESSION LONGVARCHAR,
ACCESSED TIMESTAMP,
LOCKED INTEGER
)
in particular the I<SESSION> column must be sufficiently large. I suggest
using something like up to 65535, for example I am using I<SHORT BLOB>
with MySQL.
The SESSION column must accept binary characters, in particular NUL bytes.
If it doesn't, you need to replace the I<Storable> package with I<FreezeThaw>.
L<Storable(3)>. L<FreezeThaw(3)>.
Ilya Ketris (ilya@gde.to) has pointed out, that these column names are
causing problems from time to time. He suggested to use queries like
INSERT INTO $table ("ID", "SESSION", ...
instead. This is of course higly incompatible to other engines. To fix
that problem, I have added a subclass of I<HTML::EP::Session::DBI>,
called I<HTML::EP::Session::DBIq> (quoted). You use it by just replacing
the class name in the ep-session statement.
=head2 The Cookie subclass
This class is using Cookies, as introduced by Netscape 2. When using
Cookies for the session, you have to use a slightly different syntax:
<ep-session class="HTML::EP::Session::Cookie" id="sessions"
var=session id="$@cgi->id$" expires="+1h"
domain="www.company.com" path="/"
zlib=0 base64=0>
The attribute I<id> is the cookie's name. (Cookies are name/value
pairs.) The optional attributes I<expires>, I<domain> and I<path>
are referring to the respective attributes of CG::Cookie->new().
L<CGI::Cookie(3)>.
Cookies are unfortunately restricted to a certain size, about 4096
bytes. If your session is getting too large, you might try to reduce
the cookie size by using the Compress::Zlib and/or MIME::Base64
module. This is enabled by adding the parameters I<zlib=1> and/or
I<base64=1>.
=head2 The Dumper subclass
This is, in some sense, an unusual class for sessions: All users
are sharing a single session, unlike the DBI and Cookie subclasses,
which implement one session per user. I enjoy using the Dumper
subclass anyways, for example to implement site wide preferences.
What the class does is creating a file which holds a single
hash ref. This hash ref is created using the I<Data::Dumper>
package. L<Data::Dumper(3)>.
You create a Dumper session like this:
<ep-session class="HTML::EP::Session::Dumper"
id="/var/tmp/my.session" var="prefs">
In other words, the session ID is just the name of the file.
=head1 MULTIPLE SESSION
When looking at the Cookie and Dumper subclass, the question arises:
Can I use multiple sessions within a single HTML page? Of course you
can!
However, there are a few drawbacks:
=over 8
=item 1.)
The variable $_ep_session_id$ always contains the ID of the
I<last> created session. After you have created the first
session, it will contains this sessions ID. If you create
another session, the variable will change to the new ID.
=item 2.)
You I<must> use the attributes B<var=something> and B<id=something>
with any call to I<ep-session>, I<ep-session-store>, I<ep-session-delete>
and I<ep-session-item>.
=back
=head1 AUTHOR AND COPYRIGHT
This module is
Copyright (C) 1998 Jochen Wiedmann
Am Eisteich 9
72555 Metzingen
Germany
Phone: +49 7123 14887
Email: joe@ispsoft.de
All rights reserved.
You may distribute this module under the terms of either
the GNU General Public License or the Artistic License, as
specified in the Perl README file.
=head1 SEE ALSO
L<HTML::EP(3)>, L<Apache::Session(3)>, L<DBI(3)>, L<Storable(3)>,
L<FreezeThaw(3)>, L<CGI::Cookie(3)>
=cut
( run in 1.055 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )