Looking for easy sessions using mod_perl
[prev]
[thread]
[next]
[Date index for 2005/02/18]
I'm moving from PHP to mod_perl. What a jump...
Normally in php it's as simple as:
session_start();
Then depending on your settings the session is kept in a cookie
or in the url.
I've looked into Apache::Session a bit, also Session (which is a=20
wrapper for Apache:Session.)
I set it up locally using my mysql database, but I'm getting now where=20=
fast.
Here is the code:
my $cookie =3D $r->header_in( 'Cookie' );
$r->print( "Content Type: text/plain\n\n" );
$cookie =3D~ s/SESSION_ID=3D(\w+)/$1/;
my %session;
eval {
tie %session, 'Apache::Session::MySQL', $cookie,
{ DataSource =3D> 'dbi:mysql:boysie_habitat2',
UserName =3D> 'boysie_human',
Password =3D> "h\@b!T",
LockDataSource =3D> 'dbi:mysql:boysie_habitat2',
LockUserName =3D> 'boysie_human',
LockPassword =3D> "h\@b!T",
};
};
if( $@ ) {
$r->print( "Couldn't tie session: $@" );
}
I get the following error:
null: Use of uninitialized value in substitution (s///) at=20
/Users/WebRoot/perl/index.pl line 16.
I've tried printing out the cookie to see it and get the same error for=20=
anything I try to print it with.
It seems like it's being recorded ok in mysql. I get the id fine, but=20=
the a_session column seems to be funky.
I'll copy an example below:
---------------------------------------
=05=06=03=01
e16d4be4a2f73b323184e8da1cef694d=0B_session_id
---------------------------------------
You can't see it in the copy but there are a bunch of squares (I guess=20=
mac os x's new line characters.)
Any reason why this is so difficult to get working (besides my=20
inexperience...)
Thanks,
Boysenberry
 |
Looking for easy sessions using mod_perl
Boysenberry Payne 18:43 on 18 Feb 2005
|