Solved

How to print an object and its arguments

Posted on 2006-07-12
1
171 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
Comment Utility
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
Learn the basics of while and for loops in Python.  while loops are used for testing while, or until, a condition is met: The structure of a while loop is as follows:     while <condition>:         do something         repeate: The break statement m…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

728 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now