App-Context

 view release on metacpan or  search on metacpan

lib/App/Session.pm  view on Meta::CPAN

}

#############################################################################
# html()
#############################################################################

=head2 html()

The html() method ...

    * Signature: $html = $session->html();
    * Param:  void
    * Return: $html      string
    * Throws: <none>
    * Since:  0.01

    Sample Usage: 

    $session->html();

The html() method on a session may be used by Contexts which embed session
information in a web page being returned to the user's browser.
(Some contexts do not use HTML for the User Interface and will not call
this routine.)

The most common method of embedding the session information in the HTML
is to encode the session_id in an HTML hidden variable (<input type=hidden>).
That is what this implementation does.

=cut

sub html {
    &App::sub_entry if ($App::trace);
    my ($self, $options) = @_;
    my ($session_id, $html);
    $session_id = $self->get_session_id();
    $html = "<input type=\"hidden\" name=\"app.session_id\" value=\"$session_id\">";
    &App::sub_exit($html) if ($App::trace);
    $html;
}

#############################################################################
# dump()
#############################################################################

=head2 dump()

    * Signature: $perl = $session->dump();
    * Param:     void
    * Return:    $perl      text
    * Throws:    App::Exception
    * Since:     0.01

    Sample Usage: 

    $session = $context->session();
    print $session->dump(), "\n";

=cut

use Data::Dumper;

sub dump {
    &App::sub_entry if ($App::trace);
    my ($self, $ref) = @_;
    $ref = $self if (!$ref);
    my %copy = %$ref;
    delete $copy{context};   # don't dump the reference to the context itself
    my $d = Data::Dumper->new([ \%copy ], [ "session" ]);
    $d->Indent(1);
    &App::sub_exit($d->Dump()) if ($App::trace);
    return $d->Dump();
}

sub print {
    my $self = shift;
    print $self->dump(@_);
}

1;



( run in 1.374 second using v1.01-cache-2.11-cpan-39bf76dae61 )