use Data::Dumper; $Data::Dumper::Terse = 1; $Data::Dumper::Indent = 1; use DBI; use Apache::Session::MySQL; my $dbh = DBI->connect('DBI:mysql:apache_session' . ':' . 'localhost' . ';mysql_read_default_file=/path/to/.my.cnf', undef, undef, ); ( my $sth = $dbh->prepare('SELECT id FROM sessions') )->execute; while ( my $id = $sth->fetchrow_array ) { my %session; tie %session, 'Apache::Session::MySQL', $id, { Handle => $dbh, LockHandle => $dbh }; print Dumper \%session; # you could edit or do whatever to %session here and get the # data back with the same $id later } $sth->finish; $dbh->disconnect;