You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by "F. Xavier Noria" <fx...@isoco.com> on 2002/04/28 18:55:32 UTC
Basic usage of Apache::Session::Oracle
If I understand it correctly, Apache::Session::Oracle uses a table
called "sessions" with at least two columns, one called "id", of type
"varchar2(32)", and another called "a_session", of type "long".
Say I want to store a pair of things in sessions: a reference to an
object of type User (which includes a reference to an object of type
UserManager) and a timestamp to know when we received the last request
from that session. Apart from that reference in the user, both classes
consist of primitive attributes, IDs, names, strings with SQL, and the
like.
1. Is the reference to the user storable? (My doubt here is "what
kind of things are not serializable" indeed, I have a vague idea
of this, I think I cannot store a reference to a db handler, or
a file handle, but I cannot respond accurately to that question
in general.)
2. Do I need to create more columns in the table or everything goes
to the "a_session" column?
3. Could one set up things in a way that allows the database to see
the timestamps and program a trigger to delete old sessions? Or
is there a standard idiom for doing this in a different way?
Thank you very much,
-- fxn
Re: Basic usage of Apache::Session::Oracle
Posted by Perrin Harkins <pe...@elem.com>.
> 1. Is the reference to the user storable?
Yes, but it will store the complete user object in the database, not
just a reference.
> 2. Do I need to create more columns in the table or everything
goes
> to the "a_session" column?
The latter.
> 3. Could one set up things in a way that allows the database to
see
> the timestamps and program a trigger to delete old sessions?
Yes. You will have to hack the Apache::Session code to do it, but it's
not very hard. Just make it store a timestamp in a different table. Or
put a trigger in the database to update a timestamp column when the
a_session column gets updated.
However, this implies that every time a user accesses a page you will be
updating his session. That's not true for most sites. If you really
need an accurate time for when the user last accessed a page, you will
have to make sure to update his session every time. See the information
on forcing an update in the Apache::Session docs.
- Perrin