in reply to Re^2: Testing for existence of cookies
in thread Testing for existence of cookies

if (defined($cgi->cookie('admin'))) { # cookie exists # do something } else { # no cookie # so do something else }

This is untested, but you get the point....

See here for a quick example script and some explanation.

Replies are listed 'Best First'.
Re^4: Testing for existence of cookies
by bigjoe11a (Novice) on Jun 26, 2005 at 16:26 UTC
    Ok, It work one time and that was it. I change the line to look like this if (!defined($cgi->cookie('name'))) { $msgnew = "Welcome Back, $uname"; } else { &New_Acc; } I'm not getting a 500 internal server error any more, it just won't work. When it doesn't find the cookie name. It should run a subroutine called. &New_Acc; and well it still thinks theres a cookie there, even when I deleted the cookie from my browser. Thanks joe

      You want to welcome the user back if the 'Name' cookie is not defined? Are you sure this is right? The logic in the code doesn't match what you say you want in the description.

      What's happening? You say you're not getting an error, but what are you getting? Where are you printing the message string?

      Larry

        At the beginning, Like I said, if I use if (!defined($cgi->cookie('name'))) I don't get any errors, It just doesn't work. when I tryed if (defined($cgi->cookie('name'))) I keep geting a 500 internal server error. The script won't run. I know that the ! means not defined. But thats not what I want. I want to is if one of 3 is defined and then do some thing. I have to make changes so I could get this script running, its just not running the way I want.
Re^4: Testing for existence of cookies
by bigjoe11a (Novice) on Jun 26, 2005 at 14:57 UTC
    Ok, cool, thats that worked great, how how about deleting cookies, just in case I can't find them in cgi.pm file Thanks Joe