Search code examples
phpiossafari

Cookies for Safari, safari cookie problem Deleting cookies when Safari is closed and opened


I have a php-based system, there is no problem in chromeda, but it does not keep cookies in safari, what should I pay attention to in the cookie system for safari, how do I solve this problem?

Deleting cookies when Safari is closed and opened


Solution

    1. Same-Site attribute: Safari has strict policies regarding cross-site tracking. If you want your cookie to be accessed by third-parties set SameSite=None. If you want your cookies to be accessed only by your site, SameSite=Lax or SameSite=Strict can be used. Try different values and see how it affects your cookie on safari.

    2. If your cookie is set with SameSite=None, Safari requires that the cookie is also marked with Secure, meaning it can only be transmitted over HTTPS.

    3. Setting HTTPOnly can enhance cookie security by preventing client-side scripts from accessing the cookie. Although we do not know whether safari considers this.

    4. Be sure to explicitly set a cookie expiration date

    5. Be sure the Path and Domain of your cookie are correct

    6. Safari has adjusted cookie handling on different versions of the browser. Test how your cookies are handled on different versions of safari.

    7. Safari has privacy features that can prevent JavaScript from from accessing cookies. If your using JavaScript to manipulate the cookie, safari may be blocking it.

    8. Use Safari's developer tools to inspect the cookies being set.