For Programmers: Free Programming Magazines  


Home > Archive > PERL Miscellaneous > April 2005 > Stumped on using CGI.pm cookie method









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Stumped on using CGI.pm cookie method
Don

2005-04-24, 8:56 pm

I'm trying to implement a test on the values of two cookies using the CGI.pm
approach to cookies. But, I'm getting the following error that's got me
stumped. I'm real new to Perl, and am doing my best to figure this out. I
sure could use some help with this. Thanks much. -- Don

Error messages in server log:
"Useless use of a constant in void context at wwwboard.pl line 110. Useless
use of a constant in void context at wwwboard.pl line 103"

Note: line 103 is the opening brace on the "if" statement. And, line 110
is the first line of the "eval" statement.

Start of code:
----------------------

# Check to see if client has logged in and passed Username/Password
test.
#
my $query = new CGI;
if(value=>[$query->cookie(-name=>'cpceLoggedInCookie')] ne 'true' or
value=>[$query->cookie(-name=>'cpceUsernamePasswordPassedCookie')] ne
'true')
{
# HTML code to be inserted here.
exit;
}
# Done with login test.


eval {
sub SEEK_SET() { 0; }
} unless defined(&SEEK_SET);

----------------------
End of code

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Tad McClellan

2005-04-25, 3:58 am

Don <> wrote:


Please choose one posting address and stick with it.

Thank you.


> I'm trying to implement a test on the values of two cookies using the CGI.pm



Why don't you just copy/paste the sample code given in the module's
documentation and then modify it for your situation?


> Error messages in server log:
> "Useless use of a constant in void context at wwwboard.pl line 110. Useless
> use of a constant in void context at wwwboard.pl line 103"
>
> Note: line 103 is the opening brace on the "if" statement. And, line 110
> is the first line of the "eval" statement.



If you copy/pasted the code you included into a complete program,
then the line numbers would be easier to count "by eye".

Have you seen the Posting Guidelines that are posted here frequently?


> my $query = new CGI;
> if(value=>[$query->cookie(-name=>'cpceLoggedInCookie')] ne 'true' or



That is kind of bizarre, and I wonder why you think it would work.

What did you read that made you think you could do it that way?


It is the same as:

if('value',[$query->cookie(-name=>'cpceLoggedInCookie')] ...
^ ^^
^ ^^

You have put a list into the (boolean) if-clause.

And you are comparing a *reference* to the string "true", that
comparison will always be false, making it into a useless test.

CGI.pm docs give this code:

$riddle = $query->cookie('riddle_name');

So for your situation it would be:

$riddle = $query->cookie('cpceLoggedInCookie');

Then plug it into an if-clause:

if ( $query->cookie('cpceLoggedInCookie') ne 'true' ...


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
Don

2005-04-25, 3:58 am

On Sun, 24 Apr 2005 19:50:45 -0500, Tad McClellan <tadmc@augustmail.com>
wrote:

>Don <> wrote:
>
>
>Please choose one posting address and stick with it.
>
>Thank you.
>
>
>
>
>Why don't you just copy/paste the sample code given in the module's
>documentation and then modify it for your situation?
>
>
>
>
>If you copy/pasted the code you included into a complete program,
>then the line numbers would be easier to count "by eye".
>
>Have you seen the Posting Guidelines that are posted here frequently?
>
>
>
>
>That is kind of bizarre, and I wonder why you think it would work.
>
>What did you read that made you think you could do it that way?
>
>
>It is the same as:
>
> if('value',[$query->cookie(-name=>'cpceLoggedInCookie')] ...
> ^ ^^
> ^ ^^
>
>You have put a list into the (boolean) if-clause.
>
>And you are comparing a *reference* to the string "true", that
>comparison will always be false, making it into a useless test.
>
>CGI.pm docs give this code:
>
> $riddle = $query->cookie('riddle_name');
>
>So for your situation it would be:
>
> $riddle = $query->cookie('cpceLoggedInCookie');
>
>Then plug it into an if-clause:
>
> if ( $query->cookie('cpceLoggedInCookie') ne 'true' ...

Thanks for your help.
Don

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Tad McClellan

2005-04-25, 3:58 am

Don <no@adr.com> wrote:
> On Sun, 24 Apr 2005 19:50:45 -0500, Tad McClellan <tadmc@augustmail.com>
> wrote:
>


So is "no@adr.com" going to be the one?

Do you really own or work for adr.com?

It isn't nice to use other's names without permission...

[color=darkred]


Have you done that yet?

[color=darkred]
> Thanks for your help.



If you really mean that, then please learn how to compose a proper followup.

Soon.


--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com