open RANDOM, RANDOM_DEVICE or die "Cannot open " . RANDOM_DEVICE . ": $!"; $rc = read RANDOM, $secret, $bytes; close RANDOM or die "Cannot close " . RANDOM_DEVICE . ": $!"; die "Nothing was read!" if 0 == length $rc; die "Mismatched read: $bytes vs " . length($rc) . "!" if $bytes != length $rc; # quote the binary value for inclusion in a double-quote string $secret =~ s/[\x00-\xff]/sprintf '\\%o', ord $&/gex; #### my $sessionid = $dbh->selectrow_array ( "SELECT nextval('UserSessionSeq')" ); #### my $sessiondigest = md5_hex(sprintf("%u %s", $sessionid, Voter->SECRET) #### $dbh->selectrow_array ( "SELECT UserID, Activeuser, Created, Modified" . " FROM ValidSession" . " WHERE SessionID = ?" . " AND SessionDigest = ?", undef, $sessionid, $sessiondigest ); # if a row was returned then it was a good match otherwise something is wrong (the session might have just expired as well - views are useful for that)