This works fine if a cookie already exists
use CGI::Cookie;
my %cookie = CGI::Cookie->fetch;
my $val = $cookie{'MY_COOKIE'}->value;
If there is no cookie, then the page failes with this error.
Can't call method "value" on an undefined value at /file.cgi line 23.
This test generates the same error... presumably because it's trying to do the same thing
if ( $cookie{'MY_COOKIE'}->value ) {
$val = $cookie{'MY_COOKIE'}->value;
}
How might I detect if there is no cookie or it has an empty value?
Thank you.