Hi monastry mates,
Was coding a simple search engine, where about 10 results are displayed per page. And if the user searches subsequest pages of the same search string, a cookie is used instead of repeating the whole search. But after a few different search strings are entered the page goes to Bad request (HTTP 400). For that session, all pages from the server get 400 error.
my $start_dir = $q->param("dir");
my @search_string = split / /,$q->param("search_string");
my $search_type = $q->param("search_type");
my $start_num = $q->param("start_number");
if ( ! defined ($start_num) ) { $start_num = 0; }
@search_string = getWords(@search_string);
my $search_url = $c{url}{find_cgi}."?dir=$start_dir&search_type=$searc
+h_type&search_string=".fmtSS(@search_string);
my $cookie_name = $q->param("search_string")."_dir_".$start_dir;
my $cookie_data = $q->cookie($cookie_name);
if ( defined ($cookie_data) ) {
my %cookie_hash = %{ thaw $cookie_data };
my @search_result = computeRank($search_type,%cookie_hash);
printScore($start_num,$search_url,$c{search_list_length},@sear
+ch_result);
exit;
}
my %word_score = getWordScore(...........);
if ( %word_score ) {
my @search_result = computeRank($search_type,%word_score);
$cookie_data = freeze \%word_score;
my $search_cookie = $q->cookie(-name=>$cookie_name,-value=>$co
+okie_data);
printScore($start_num,$search_url,$c{search_list_length},@sear
+ch_result);
}
else {
print "<p>No results found";
}