I am trying to verify cookie exists to block pop-up from showing. I have tried 10 different pieces of code and all fail. I think the problem resides in waht I am using for c_name. Latest attempt below. I have tried the cookie name and the domain name. Neither work.
<script>
function checkForJALACookie(c_name){
var cookieFound = Cookies.get(c_name);
// alert("cookiefound = " + cookieFound); <-undefined
if (cookieFound) {
alert("Cookie Found");
}
else {
alert("Cookie Not Found");
}
}
</script>
The storage inspector shows cookie name CGISESSID. I set the cookie in my code
If that site is live I think you should remove the alerts and use only console.log.
For a non-techy visitor a bunch of alerts would likely put them off. And a non-techy visitor is not likely to look at their dev tools and see the log messages.
my $domain = $ENV{'HTTP_HOST'};
sub SetUserSessionCookie
{
my $printresult = "";
my ($sname,$sid) = @_;
my $sessioncookie = new CGI::Cookie(-name=>$sname,-value=>$sid,- expires=>$session_cookie_timeout,-path=>'/',-domain=>$domain,-secure=>0);
$printresult = print header(-Cookie=>[$sessioncookie],-type=>"text/html");
warn("printresult: '$printresult'");
}```