gman has asked for the wisdom of the Perl Monks concerning the following question:
package myTest::Index; use strict; use DBI; use base 'CGI::Application'; use CGI::Application::Session; use Data::Dumper; .... .... sub home { # $self->start_mode('home'); my $self = shift; my $tmpl = $self->load_tmpl('index.tmpl'); my $session = $self->session; my $data = $session->param_hashref(); use myTest::module1; my $moduleRef = new myTest::module1; $moduleRef->add_item(); # session changes in myTest::module1 +here are not reflected in # main session $session->param("key1","value1"); # Works as expected $tmpl->param(DATA => Dumper($data)); return $tmpl->output; }
package myTest::module1; use base qw/myTest::Index/; use strict; use warnings; sub add_item { my $self = shift; my @array1 = ('data1','data2'); my $cart = $self->session->param('_CART') || []; push @{ $cart }, @array1; $self->session->param('_CART', $cart); return; } 1;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: CGI::Application::Session and Inheritance
by dragonchild (Archbishop) on Apr 19, 2005 at 18:02 UTC | |
by gman (Friar) on Apr 19, 2005 at 18:08 UTC | |
by dragonchild (Archbishop) on Apr 19, 2005 at 18:09 UTC | |
by gman (Friar) on Apr 19, 2005 at 18:39 UTC | |
by mpeters (Chaplain) on Apr 19, 2005 at 18:53 UTC | |
|
Re: CGI::Application::Session and Inheritance
by Joost (Canon) on Apr 19, 2005 at 18:07 UTC |