Hammy has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks, I am trying to understand the use of Apache::Session::MySQL and I have what appears to be a couple of simple questions. I have found the following code in a number of pages on the Net as an example for setting up sessions. My question is how does the code below know where to find my table and a field to update with in my table? Is 'dbi:mysql:sessions' supposed to be replaced with 'DBI:mysql:database=$database;host=$hostname;port=$port'? I have a feeling I am misunderstanding something somewhere, but I can't figure out what it is. Thank You.
# pull in the required packages use Apache::Session::MySQL; use Apache; use strict; # read in the cookie if this is an old session my $r = Apache->request; my $cookie = $r->header_in('Cookie'); $cookie =~ s/SESSION_ID=(\w+)/$1/; # create a session object based on the cookie we got from the # browser, or a new session if we got no cookie my %session; eval { tie %session, 'Apache::Session::MySQL', $cookie, {DataSource => 'dbi:mysql:sessions', UserName => $db_user, Password => $db_pass, LockDataSource => 'dbi:mysql:sessions', LockUserName => $db_user, LockPassword => $db_pass, }; }; if ($@) { # could be a database problem die "Couldn't tie session: $@"; } # might be a new session, so let's give them their cookie back my $session_cookie = "SESSION_ID=$session{_session_id};"; $r->header_out("Set-Cookie" => $session_cookie);