Solved

How to print an object and its arguments

Posted on 2006-07-12
1
180 Views
Last Modified: 2013-12-25
An HTML form sends input to this cgi program.  I would like to know how to print the value of
one or all of the cookie's values out of the object.  At present it outputs a blank string if cookies are enabled, but generates a server error indicating:

"uninitialized value in concatenation or string" at the line indicated.





#!/usr/bin/perl -wT
#
#

use strict;
use lib '/Volumes/mojo/toppweb/ttest/squid/squidperl';
use CGI qw( :standard);
use CGI::Cookie;

use constant SOURCE_CGI => "/tsquid/ctest2.html";

chomp (my $inval = param("cart_id") );
my $q= new CGI;

my $kookie = $q->cookie(-name => "tcooky",
                  -value => $inval,
                  -path  => "mt1.stanford.edu",
                   );

                              
if ( $inval )  {
#   print $q->redirect( SOURCE_CGI );
  print
        $q->header( -type => "text/html", -expires => "-1d" ),                  
        $q->start_html("Cookie Enabled"),
        $q->h1("Cookies Enabled [" . $q->cookie('tcooky') ."]"),           <--- error occurs here
       $q->p( "Your browser IS accepting cookies ",
       $q->a( { -href => SOURCE_CGI }, "Return" ),
       "."
       ),
       $q->end_html;



} else {
  print
        $q->header( -type => "text/html", -expires => "-1d" ),                   
        $q->start_html('Cookie Disabled'),
        $q->h1("Cookies Disabled " ),
       $q->p( "Your browser is not accepting cookies. ",
       $q->a( { -href => SOURCE_CGI }, "Return" ),
       "."
       ),
       $q->end_html;
}
exit (0);




0
Comment
Question by:gmanpert
1 Comment
 
LVL 8

Accepted Solution

by:
Perl_Diver earned 500 total points
ID: 17093020
you define a cookie but never read or write a cookie. The CGI module can handle the cookies, you don't need to also use CGI::Cookie. See if this helps you:

http://perldoc.perl.org/CGI.html#HTTP-COOKIES
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered how to display how many visitors you have online. In this tutorial I will show you an easy but effective way to display the number of online visitors in WhizBase. In this article I assume you have read my previous articles and know …
It is becoming increasingly popular to have a front-page slider on a web site. Nearly every TV website,  magazine or online news has one on their site, and even some e-commerce sites have one. Today you can use sliders with Joomla, WordPress or …
The viewer will learn how to dynamically set the form action using jQuery.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question