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

To fix the "set SameSite cookie to none" warning in PHP, you will need to specify the SameSite attribute when you set the cookie. Here is an example of how to do it:

<?php

setcookie('cookie_name', 'cookie_value', [
  'expires' => time() + 86400, // expires in 1 day
  'path' => '/',
  'domain' => 'example.com',
  'secure' => true,
  'httponly' => true,
  'samesite' => 'None',
]);

Watch a course Learn object oriented PHP

The SameSite attribute can be set to 'Strict', 'Lax', or 'None'. The default value is 'Lax', which means that the cookie will not be sent with cross-site requests. Setting it to 'None' allows the cookie to be sent with cross-site requests, but only if the request is made using Secure and HttpOnly cookies.

It is important to note that the SameSite attribute is only supported in modern browsers. If you need to support older browsers, you will need to use a polyfill or work around the warning in some other way.