0

I am trying to get my a cookie to work within an iframe on another site url.

But when I add this new method of setting cookie options in an array, the cookie is not setting at all even not viewing in the iframe.

Here is my previous php set cookie which works fine on its own url, but does not work in iframe.

public function authenticate()
{
    $this->loadCrypt();
    setcookie(
        '_siteauth', 
        Crypt::encrypt(site()->password),
        time() + 86400,
        '/'
    );
    return true;
}

Then here is my new version thats not working when outputting options as an array as per php docs for 7.3 above.

public function authenticate()
{
    $this->loadCrypt();
    setcookie(
        '_siteauth',
        Crypt::encrypt(site()->password),
        [
            'expires' => time() + 86400,
            'path' => '/',
            'samesite' => 'None'

        ]
    );
}

The syntax above is exactly the same as the one in this question...

How to fix "set SameSite cookie to none" warning?

I'm getting no errors, the second set cookie method is not even setting a cookie, when the first one at least sets, just not when not inside an iframe on a different domain.

Any ideas would be great thanks.


Checked response header and there is a warning icon against Set-Cookie which I didn't have originally. But it doesn't tell me what the error is and why?

enter image description here

joshmoto
  • 4,472
  • 1
  • 26
  • 45
  • Have you checked what the response headers look like in each case? Is the `Set-Cookie` header present? If so, what are the significant differences, if any? – CBroe Mar 11 '21 at 12:12
  • @CBroe great shout there is a problem, not sure what, doesn't actually tell me what the problem is, see screenshots https://imgur.com/a/xGhDdyu – joshmoto Mar 11 '21 at 12:24

0 Answers0