Support » Plugin: DD Last Viewed » After Chrome update Cookies default to SameSite=Lax

  • Resolved henrygng

    (@henrygng)


    Thanks for this cool plugin!

    I came across a limitation when the site is embedded in an external site the cookies do not work, after doing a bit of research found that this is a change on the way Google Chrome works with cookies ref.

    The solution is to add this “; SameSite=None; Secure” when setting the cookie on the file js/ddLastViewedFront.min.js, I tried it and it works, putting it here just in case is helpful to someone and hopefully it will be integrated into the main plugin soon.

    // the complete unminified version on js/ddLastViewedFront.js would be
    document.cookie = cookie['name'] + "=" + (cookie['list']) + "; expires=" + expires + "; path=" +cookie['path'] + "; SameSite=None; Secure";

    I’m using the Set cookie by Javascript option so the above code works, a similar change (add SameSite=None; Secure) needs to be made on the PHP side to make it work as well.

    Here is the change on PHP side, last-viewed.php line 150:
    from
    setcookie($cookie['name'], $cookie['list'], $cookie['expire'], $cookie['path']);
    to
    setcookie($cookie['name'], $cookie['list'], array('expires' => $cookie['expire'], 'path' => $cookie['path'], 'samesite' => 'None', 'secure' => true));

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.