File: show-cookies.html

package info (click to toggle)
libhtml-mason-perl 1%3A1.58-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,796 kB
  • sloc: perl: 8,618; sh: 49; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 1,103 bytes parent folder | download | duplicates (11)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<%doc>
 This is actually more complicated than it needs to be.

 You could simply say:
  $cookies = UNIVERSAL::can("Apache::Cookie", "fetch") ? Apache::Cookie->fetch : CGI::Cookie->fetch;
 on the assumption that at least one method will work.

 Examining the value of $m->ah->args_method directory is ugly :)
</%doc>

<h3> Cookies </h3>
<%perl>
  my $cookies;
  my $loaded_cookies;
  if ($m->can("ah")) {
    if ($m->ah->args_method eq 'CGI') {
      $cookies = CGI::Cookie->fetch;
      $loaded_cookies = "mod_perl + CGI";
    } elsif ($m->ah->args_method eq 'mod_perl') {
      $cookies = Apache::Cookie->fetch;
      $loaded_cookies = "mod_perl + Apache::Request";
    }
  }
  elsif (UNIVERSAL::can("CGI::Cookie", "fetch")) {
    $cookies = CGI::Cookie->fetch;
    $loaded_cookies = "CGI";
  }
  if ($loaded_cookies) {
</%perl>
<ul>
%  foreach my $key (sort keys %$cookies) {
<li><b><% $key %></b>: <% $cookies->{$key}->as_string |h%>
%  }
</ul>
<p> Cookies loaded with <% $loaded_cookies |h%> </p>
% } else {
<p> Unable to figure out how to get cookies </p>
% }

<%attr>
title => "Cookies"
</%attr>