1

I've got a strange Laravel error today. The message is: enter image description here

It clearly states that there is an undefined array index. However, when I looked at the rendered blade file mentioned here, and checked line 272 I got this:

<?php if(isset($_COOKIE[$_COOKIE['userhash'] . '-surgery'])): ?>

$_COOKIE['userhash'] is always set. As seen on the above image, it's value is 70c0a3a1. How is it possible that PHP (or Laravel) throws an error inside an isset statement? How can I solve this issue?

Balázs Varga
  • 1,797
  • 2
  • 16
  • 32
  • 2
    Use `!empty` instead of [isset](http://php.net/isset). Read the documentation how both work. – Mike Doe Oct 31 '18 at 08:38
  • The error you are looking at is error 3 out of 3. What does error 1/3 say? Usually fixing the first error will help solve the problem. You have to scroll further down the error page to get error 1/3. – Patrick Oct 31 '18 at 09:15
  • Changing `isset` to `!empty` solved the problem... I did't aware that in php `isset` doesn't mean is set, but is not set to null, and fails on checking really unset values. – Balázs Varga Oct 31 '18 at 13:28

1 Answers1

0

Plese try this:

First you can check ($_COOKIE['userhash']) is set or not as

isset($_COOKIE['userhash'])

Then you can try this :

if(isset($_COOKIE['userhash']) && isset($_COOKIE[$_COOKIE['userhash'] . '-surgery']))`
Jasmel Singh
  • 111
  • 1
  • 6
  • It's already checked a line above, and as my example shows `userhash` is set correctly. Your code does exactly the same thing as mine, and fails becaouse of the exact same reason... – Balázs Varga Oct 31 '18 at 13:14