About the problem that the page in the iframe cannot set cookies (sessions)

  • content
  • comment
  • relevant

The reason is that the default value of SameSite in the browser is Lax

See https://www.ruanyifeng.com/blog/2019/09/cookie-samesite.html

Try the following methods respectively:

1. Direct setting of php code

 header('Set-Cookie: cross-site-cookie=name;  SameSite=None; Secure'); setcookie('cross-site-cookie', 'name', ['samesite' => 'None', 'secure' => true]); //This method seems feasible, but it needs to have a base class in the project, which can be set uniformly session_set_cookie_params(['samesite' => 'None', 'secure' => true]); $currentCookieParams = session_get_cookie_params(); $cookie_domain= 'your domain'; if (PHP_VERSION_ID >= 70300) { session_set_cookie_params([ 'lifetime' =>  $currentCookieParams["lifetime"], 'path' => '/', 'domain' => $cookie_domain, 'secure' => "1", 'httponly' => "1", 'samesite' => 'None', ]); } else { session_set_cookie_params( $currentCookieParams["lifetime"], '/;  samesite=None', $cookie_domain, "1", "1" ); } session_start(); //Waiting for verification

comment

zero Comments

Post reply

Your email address will not be disclosed. Required items have been used * tagging