Im looking at Apache::Session and trying to figure out what it does. What I 
want
to do is tie sessions to a particular record in a database table. From what 
I
can tell, Apache::Session will only give generic sessions, of which I know
nothing about the user untill they give me information during that 
particular
session.

I have a table with some basic user information (first name, last name, 
address,
phone number, etc...). Apache::Session says I have to have a column named id
and one called a_session. It says that the id column must be primary key, 
but
my table already has a primary key, an auto-increment column for the userid.

What i did was created the two columns, and hoped it would work without the 
id
column being the primary key. I stuck a 32 character string I got from
Sys::UniqueID in the id column and tried to do:

...
my($dbh) = DBI->connect( MISANet::Util::DatabaseOpts::getOpts() );

my($id) = '00003D898BE8C0A801250000229B0001';

my(%hash);
tie %hash, 'Apache::Session::MySQL', $id, {
  Handle     => $dbh,
  LockHandle => $dbh
};

$r->content_type('text/html');
$r->send_http_header();

$r->print( "<html><head><title>Dummy</title></head><body><div>Hello,
$hash{firstName} $hash{lastname}</div></body></html>" );
...

in a perlHandler where firstName and lastName are columns in the database. 
%hash
never gets defined and $! dosent report anything.

So now Trying to decide what to do, in a perlHeaderParserHandler Ill just 
get an
id from Sys::UniqueID, send it to the browser each request in a cookie or
whatever, then use DBI::Tie to reinstate the session for each request.
(Thinking about it, that sounds easier than Apache::Session anyways) What do
you guys think? Am I using Apache::Session wrong, or are there better
alternatives than what Ive came up with?

Thanks in advance for the input.

Todd W.


_________________________________________________________________
MSN Photos is the easiest way to share and print your photos: 
http://photos.msn.com/support/worldwide.aspx

Reply via email to