I just wish it were even possible to roll my own at this stage! ;-)I was jokingly referring to the 'googling' you did when you came up with all sorts of references to getting the $ENV variable and parsing it! Just don't do it please :)
As for CGI.pm, wouldn't CGI.pm's "stickyness" be the default behavior? I see where there's a pragma called "-nosticky". I can't seem to pass the variables to the second script, even though I successfully passed them to the first script (and I suspect it's because the variables were in a form and CGI.pm likes that). So, am I correct in my understanding that CGI.pm won't pass the form variables a second time because there's no form?I am going to pass on comeenting here. Yes, as I recall, CGI.pm's default is sticky, but it is a LONG time since I used it that way.
I've been trying to play with CGI::Session, but I can't get it to work for me. I don't know if it's because I'm trying to save ALL my CGI form variables PLUS my TMPL_VAR variables... Is that even possible?Sheesh! Why does everybody have trouble getting CGI::Session to work! It's easy. OK, here we go:
and make sure that the 'a_session' is at least a BLOB size field.SET FOREIGN_KEY_CHECKS=0; #---------------------------- # Table structure for sessions #---------------------------- CREATE TABLE `sessions` ( `id` varchar(32) NOT NULL default '', `a_session` text NOT NULL, UNIQUE KEY `id` (`id`) ) TYPE=MyISAM;
my $config = { DSN => 'DBI:mysql:session', MySQLunm => 'ipsofalco', MySQLpwd => 'ipsoquango', }; my $dbh = &createDBconnection( $config->{DSN}, $config->{MySQLunm}, $c +onfig->{MySQLpwd} ); # Get a CGI object, it will be filled if a form was #submitted and will have a cookie in teh header #if one had been set. my $q = new CGI; #Initialize the session, if their is a cookie in the #CGI object then the CGISESSID will be the value of an #existing session, otherwise it creates a new session my $session = new CGI::Session("driver:MySQL", $q, {Handle=>$dbh}); #$rdcookie is the value of the cookie that was already # in the header read=past tense in this case. my $rdcookie = $q->cookie("CGISESSID"); #$id is the session id (an MD5 hash) of the session. my $id = $session->id(); # Set cookie with new expire time my $cookie = $q->cookie(-name=>'CGISESSID', -value=>$session->id, -exp +ires=>'+1d');
Does nothing more than get a hash of an item and adds it to the CART value(a list of hashes) which is saved in the session parameters.sub addItemCart { my ($cgi, $session, $orderitem) = @_; my $orderitem = &getItemForCart($cgi, $session); # get current cart contents my $cart = $session->param("CART") || []; # add selected item push @{$cart}, $orderitem; # update the CART in the session $session->param( "CART", $cart ); $session->flush(); return displayCart($cgi, $session); }
and in this case display the updated cart.sub clrCart { my ($cgi, $session) = @_; $session->clear(["CART"]); $session->flush(); return &displayCart($cgi, $session); }
To see some more code - much more complete, have a look at jdtoronto's scratchpad The full working version is posted there.
In reply to Re:^^ HTML::Template, CGI, pass template params to next script
by jdtoronto
in thread HTML::Template, CGI, pass template params to next script
by Lori713
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |