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
wrapper for Apache:Session.)
I set it up locally using my mysql database, but I'm getting now where
fast.
Here is the code:
my $cookie = $r->header_in( 'Cookie' );
$r->print( "Content Type: text/plain\n\n" );
$cookie =~ s/SESSION_ID=(\w+)/$1/;
my %session;
eval {
tie %session, 'Apache::Session::MySQL', $cookie,
{ DataSource => 'dbi:mysql:boysie_habitat2',
UserName => 'boysie_human',
Password => "h\@b!T",
LockDataSource => 'dbi:mysql:boysie_habitat2',
LockUserName => 'boysie_human',
LockPassword => "h\@b!T",
};
};
if( $@ ) {
$r->print( "Couldn't tie session: $@" );
}
I get the following error:
null: Use of uninitialized value in substitution (s///) at
/Users/WebRoot/perl/index.pl line 16.
I've tried printing out the cookie to see it and get the same error for
anything I try to print it with.
It seems like it's being recorded ok in mysql. I get the id fine, but
the a_session column seems to be funky.
I'll copy an example below:
---------------------------------------
e16d4be4a2f73b323184e8da1cef694d_session_id
---------------------------------------
You can't see it in the copy but there are a bunch of squares (I guess
mac os x's new line characters.)
Any reason why this is so difficult to get working (besides my
inexperience...)
Thanks,
Boysenberry
Thread Next