Welcome to WebmasterWorld Guest from 54.160.131.144

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

Cookie question

works in one script, not in another

     

basenotes

9:33 pm on Oct 25, 2004 (gmt 0)

10+ Year Member



Hi folks

I'm not an expert in coding Perl, but thanks to my father's insistance on learning BASIC at the age of 7, I'm not too bad at editing scripts and adding a few bits too them (sometimes!)

I have a cookie query.

In one script, I'm using the following code to read a cookie which has been set by a different script:


===================================
use CGI qw(header cookie);
.
.
.
$theCookie = $query->cookie('username');

===================================

This works fine, and I can use the string '$theCookie' for what I need.

However, when I use the same code in another script, it doesn't work (I get a 500 error) and my host's perl tester gives a response of:


===================================
- 255 perl returned nonzero status
Global symbol "$theCookie" requires explicit package name at /kunden/homepages/22/d83025052/htdocs/basenotes/cgi-bin/auction.cgi line 28.
Global symbol "$query" requires explicit package name at /kunden/homepages/22/d83025052/htdocs/basenotes/cgi-bin/auction.cgi line 28.
/kunden/homepages/22/d83025052/htdocs/basenotes/cgi-bin/auction.cgi had compilation errors.
STDOUT OK STDERR OK
===================================

ANyone have any ideas as to what would cause it to work in one and not another. Is there a bit of code I've missed?

upside

11:30 pm on Oct 25, 2004 (gmt 0)

10+ Year Member



You need to declare the variable $theCookie probably like this:

[b]my[/b] $theCookie = $query->cookie('username');

quebrada

5:36 am on Oct 27, 2004 (gmt 0)

10+ Year Member



You can also take out the pragma use strict;

It is better not to use global variables at all or at least confine them to a name space, which is what the error message is stating.

Q

 

Featured Threads

Hot Threads This Week

Hot Threads This Month