my $Cookie1 = $cgi->cookie('C1'); my $Cookie2 = $cgi->cookie('C2'); my ($f1, $f2); if (cookie('C2')) { # found a cookie! my $sth = $dbh->prepare("SELECT field_1, field_2 FROM tablename WHERE field_3='?'") or "Error"; $sth->execute(cookie('C2')) or "Error"; if (my $rec = $sth->fetchrow_hashref) { $Cookie2 = cookie('C2'); $f1 = $rec->{field_1}; $f2 = $rec->{field_2}; #### if (my $rec = $sth->fetchrow_hashref) { $Cookie2 = cookie('C2'); $f1 = $rec->{field_X};