Results 1 to 5 of 5
  1. #1
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,238
    Plugin Contributions
    1

    Default Samesite cookie requirement

    I've seen a number of posts referencing the samesite cookie requirement now being enforced by browsers. The effect of which seems to be issues checking out with certain payment modules and browser console warnings, the latter of which may be affecting SE rankings if I read this post correctly, https://www.zen-cart.com/showthread....85#post1374085

    I see that a fix is included in the upcoming release of ZC v1.57a. In the interim and for those who are not ready to upgrade to that version, should the v1.57a changes to the two occurrences of init_sessions.php be applied to all older ZC versions?
    Simon

  2. #2
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    9,144
    Plugin Contributions
    11

  3. #3
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,238
    Plugin Contributions
    1

    Default Re: Samesite cookie requirement

    Quote Originally Posted by dbltoe View Post
    Yes that's the post I referred to. Although the code is slightly different in the v1.57a release, being:

    Code:
    //session_set_cookie_params(0, $path, (zen_not_null($cookieDomain) ? $domainPrefix . $cookieDomain : ''), $secureFlag, TRUE);
    $samesite = (defined('COOKIE_SAMESITE')) ? COOKIE_SAMESITE : 'lax';
    if (!in_array($samesite, array('lax', 'strict', 'none'))) $samesite = 'lax';
    
    if (PHP_VERSION_ID < 70300) {
        session_set_cookie_params(0, $path .'; samesite='.$samesite, (zen_not_null($cookieDomain) ? $domainPrefix . $cookieDomain : ''), $secureFlag, TRUE);
    } else {
        session_set_cookie_params(array(
            'lifetime' => 0,
            'path' => $path,
            'domain' => (zen_not_null($cookieDomain) ? $domainPrefix . $cookieDomain : ''),
            'secure' => $secureFlag,
            'httponly' => TRUE,
            'samesite' => $samesite
        ));
    } else {
      session_set_cookie_params(0, $path, (zen_not_null($cookieDomain) ? $domainPrefix . $cookieDomain : ''), $secureFlag, true);
      ini_set('session.cookie_samesite', $samesite);
    }
    Last edited by simon1066; 22 Oct 2020 at 11:56 AM. Reason: spellling
    Simon

  4. #4
    Join Date
    Feb 2009
    Location
    UK
    Posts
    1,238
    Plugin Contributions
    1

    Default Re: Samesite cookie requirement

    Quote Originally Posted by simon1066 View Post
    Yes that's the post I referred to. Although the code is slightly different in the v1.57a release, being:

    Code:
    //session_set_cookie_params(0, $path, (zen_not_null($cookieDomain) ? $domainPrefix . $cookieDomain : ''), $secureFlag, TRUE);
    $samesite = (defined('COOKIE_SAMESITE')) ? COOKIE_SAMESITE : 'lax';
    if (!in_array($samesite, array('lax', 'strict', 'none'))) $samesite = 'lax';
    
    if (PHP_VERSION_ID < 70300) {
        session_set_cookie_params(0, $path .'; samesite='.$samesite, (zen_not_null($cookieDomain) ? $domainPrefix . $cookieDomain : ''), $secureFlag, TRUE);
    } else {
        session_set_cookie_params(array(
            'lifetime' => 0,
            'path' => $path,
            'domain' => (zen_not_null($cookieDomain) ? $domainPrefix . $cookieDomain : ''),
            'secure' => $secureFlag,
            'httponly' => TRUE,
            'samesite' => $samesite
        ));
    } else {
      session_set_cookie_params(0, $path, (zen_not_null($cookieDomain) ? $domainPrefix . $cookieDomain : ''), $secureFlag, true);
      ini_set('session.cookie_samesite', $samesite);
    }
    Sorry the above code is incorrect, from github it is:

    Code:
    $samesite = (defined('COOKIE_SAMESITE')) ? COOKIE_SAMESITE : 'lax';
    if (!in_array($samesite, ['lax', 'strict', 'none'])) $samesite = 'lax';
    
    
    if (PHP_VERSION_ID >= 70300) {
      session_set_cookie_params([
        'lifetime' => 0,
        'path' => $path,
        'domain' => (zen_not_null($cookieDomain) ? $domainPrefix . $cookieDomain : ''),
        'secure' => $secureFlag,
        'httponly' => true,
        'samesite' => $samesite,
      ]);
    } else {
      session_set_cookie_params(0, $path, (zen_not_null($cookieDomain) ? $domainPrefix . $cookieDomain : ''), $secureFlag, true);
      ini_set('session.cookie_samesite', $samesite);
    }
    Simon

  5. #5
    Join Date
    Sep 2009
    Location
    Stuart, FL
    Posts
    12,477
    Plugin Contributions
    88

    Default Re: Samesite cookie requirement

    Quote Originally Posted by simon1066 View Post
    I've seen a number of posts referencing the samesite cookie requirement now being enforced by browsers. The effect of which seems to be issues checking out with certain payment modules and browser console warnings, the latter of which may be affecting SE rankings if I read this post correctly, https://www.zen-cart.com/showthread....85#post1374085

    I see that a fix is included in the upcoming release of ZC v1.57a. In the interim and for those who are not ready to upgrade to that version, should the v1.57a changes to the two occurrences of init_sessions.php be applied to all older ZC versions?
    Quote Originally Posted by dbltoe View Post
    Yes, that code I posted is slightly different from the implementation chosen for Zen Cart base inclusion. I'll note that I've seen some sites where ini_set is in the PHP 'disallowed' functions list; that's why I've chosen that alternate implementation.

 

 

Similar Threads

  1. SSL Requirement
    By Burty in forum PayPal Website Payments Pro support
    Replies: 14
    Last Post: 21 Jun 2011, 04:56 PM
  2. Fax number requirement
    By jbarrick in forum Managing Customers and Orders
    Replies: 6
    Last Post: 17 Aug 2009, 06:37 PM
  3. Unusual coupon requirement
    By Ryk in forum Discounts/Coupons, Gift Certificates, Newsletters, Ads
    Replies: 4
    Last Post: 16 Apr 2009, 11:27 PM
  4. Server requirement Error
    By jennib in forum General Questions
    Replies: 2
    Last Post: 24 Oct 2006, 09:17 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR