$main::cookie_name = $cgi->param('cookie_name'); $main::full_url = $ENV{SERVER_URL} . $ENV{SCRIPT_NAME}; $main::domain = $cgi->param('domain'); $main::path = $cgi->param('path'); $main::cookie_value = $cgi->param('cookie_value'); $main::domain ||= '.mybc.com'; $main::path ||= '/'; $main::cookie_value ||= 'na'; #### $main::cookie_value ||= 'na'; #### my $cookie = $cgi->cookie( -name => $main::cookie_name, -value => 1, # also this one can't be 0 or undef! -expires=> 1, -path => $main::path, -domain => $main::domain, ); #### sub set_cookie { my $cgi = shift; unless ($main::cookie) { $main::cookie = $cgi->cookie( -name => $main::cookie_name, -value => $main::cookie_value, -expires=> '+1h', -path => $main::path, -domain => $main::domain, ); print CGI::redirect(-location => $main::full_url, -cookie => [$main::cookie]); exit; } } #### sub remove_cookie { my $cgi = shift; $DB::single = 1; if ($main::cookie) { my $cookie = $cgi->cookie( -name => $main::cookie_name, -value => 1, # also this one can't be 0 or undef! -expires=> 1, -path => $main::path, -domain => $main::domain, ); print CGI::redirect(-location => $main::full_url, -cookie => [$cookie]); exit; } } #### my ($r_html_table, $r_html_select) = @{$_[0]}{qw(html_table html_select)}; #### sub parse_all_cookies { my ($r_html_table, $r_html_select) = @{$_[0]}{qw(html_table html_select)}; $$r_html_table = qq| |; foreach (keys %main::cookies) { $$r_html_select .= ""; $$r_html_table .= ""; } $$r_html_table .= "
Cookie NameContent
$_".$main::cookies{$_}."
"; } ##
## my ($html_cookie_table, $html_cookie_select); parse_all_cookies({ html_table => \$html_cookie_table, html_select => \$html_cookie_select, }); #### use HTML::Entities; my ($html_cookie_table, $html_cookie_select) = parse_all_cookies( \%cookies ); sub parse_all_cookies { my $cookies = shift; my $table = qq| |; my $select = ''; while (my ( $name, $value ) = each %$cookies) { encode_entities( $name ); encode_entities( $value ); $select .= ""; $table .= ""; } $table .= "
Cookie NameContent
$name".$value."
"; return ( $table, $select ); }