in reply to Fetching cookies without errors?

If you want to fetch the value of $cookies{'CGISESSID'}, why do you check whether $cookies{'name'} exists?

Maybe all you need to do is to check whether $cookies{'CGISESSID'} exists?

Replies are listed 'Best First'.
Re^2: Fetching cookies without errors?
by Dazz45X (Novice) on Aug 23, 2017 at 15:13 UTC
    Thank you for your reply Corion but it doesn't seem to matter that much the problem is with the ->value. If a cookie doesn't exist it flags a 'Can't call method "value" on an undefined value at line #' because it's trying to read a value from a cookie that doesn't exist? I was using the if (exists $cookies line to lose the error but when a cookie does exist the if line seems to stamp on the data leaving it undef?
      if (exists $cookies line to lose the error but when a cookie does exist the if line seems to stamp on the data leaving it undef?

      That will be because in your sample code you overwrite the %cookies hash immediately on the next line. Don't do that if the hash already exists (it's pointless).

        Thank you Hippo I think that was it... two suggestions from you guys and I'm smiling again. Thanks so much to all