Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

How to print an object and its arguments

Posted on 2006-07-12
1
Medium Priority
?
186 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 8

Accepted Solution

by:
Perl_Diver earned 1500 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

Google Certified Professional - Cloud Architect

This course (1 of 3) is designed to help students who are interested in Google Cloud Platform (GCP) to become familiar with the platform, navigate the console and learn its capabilities. It will also prepare students for the Google Cloud Architect certification exam.

Question has a verified solution.

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

In this tutorial I will focus on how to use WhizBase as a tool for sending ICQ messages to ICQ. Here I will use a new technology in WhizBase, published in WhizBase 5.1 version. In this tutorial I will use 3 files, pager.wbsp for the processing, e…
Making a simple AJAX shopping cart Couple years ago I made my first shopping cart, I used iframe and JavaScript, it was very good at that time, there were no sessions or AJAX, I used cookies on clients machine. Today we have more advanced techno…
Learn the basics of lists in Python. Lists, as their name suggests, are a means for ordering and storing values. : Lists are declared using brackets; for example: t = [1, 2, 3]: Lists may contain a mix of data types; for example: t = ['string', 1, T…
Learn the basics of if, else, and elif statements in Python 2.7. Use "if" statements to test a specified condition.: The structure of an if statement is as follows: (CODE) Use "else" statements to allow the execution of an alternative, if the …

715 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