I pass a session id in the query string between invocations for my
current project (only if the client does not support Cookies). My main
handler is also responsible for creating an Apache::Request object right
at the beginnig of the handler invocation. sub components rely on the
information found in the $apr object.
For GET's everything is fine, for POSTs the Apache::Request->new will
not look at the query string, because it is a POST. Fine.
So I have two solutions to pass my session id around:

1.) put it into the form data as a hidden field
2.) When the Apache::Request is built, merge it with the Query String
args.

I decided to go for solution 2.

Question: Does this make sense? Should I have done it differently? Will
I lose this ability in a future version of Apache::Request (some
comments in Request.pm seem to indicate that)?

Thanks in advance
  Tobias Hoellrich, Adobe Systems


sub handler {
  my $r           = shift;
  my $apr;
  ...
  # generate an Apache Request object: if this is a POST request,
  # the 'new' will read from STDIN the posted data, otherwise it
  # will read the GET arguments from QUERY_STRING. We always want
  # to read the information in the Query String, because it may
  # contain important session informaion. So in case we have
  # a POST request we also read the requests args and put them into
  # the Apache::Request.
  $apr=Apache::Request->new($r);
  if ($r->method eq 'POST') {
    # merge ARGS data into Apache::Request table for POST request
    my %args=$r->args;
    my $tab=$apr->parms;
    foreach (keys %args) {
      $tab->set($_,$args{$_});
    }
  }


Reply via email to