title: MVC5 Cookie and same site problem with chrome
body: <p>I'm trying to build an ECommerce with MVC5 with the following tools:
  - Visual Studio 2017, Oracle DB 11g, Entity Framework 6, .NET Framework 4.6.2, I'm using https with a void certificate for testing. I'm creating my own cookies inside the application to save users choices and favorites items, I add items manually by removing the cookie and place the new updated one after every item added or removed by the customer, ever thing is okay on Firefox, but when I try to view the application from Chrome I got the following message:</p>
  
  <blockquote>
    <p>A cookie associated with a resource at <a href="http://localhost/" rel="nofollow noreferrer">http://localhost/</a> was set with <code>SameSite=None</code> but without <code>Secure</code>. It has been blocked, as Chrome now only delivers cookies marked <code>SameSite=None</code> if they are also marked <code>Secure</code>.</p>
  </blockquote>
  
  <p>Here is my creation cookie code:</p>
  
  <pre class="lang-cs prettyprint-override"><code>public HttpCookie CookieWareFromBrowser ()
  {
      var ItemsCart = HttpContext.Current.Request.Cookies.Get(Models.StaticModels.CookiesManagedStrings.ItemsCart);    
      if (ItemsCart==null)
      {
          HttpCookie _ItemsCart = new HttpCookie(Models.StaticModels.CookiesManagedStrings.ItemsCart);
  
  
          _ItemsCart.Values.Add(Models.StaticModels.CookiesManagedStrings.Items, "|");                                       
          _ItemsCart.Values.Add(Models.StaticModels.CookiesManagedStrings.ItemsCount, "0");
  
          _ItemsCart.Expires = System.DateTime.Now.AddDays(1);
  
          HttpContext.Current.Request.Cookies.Set(_ItemsCart);
  
  
          HttpContext.Current.Response.SetCookie(_ItemsCart);
          HttpContext.Current.Response.Flush(); 
  
          return _ItemsCart;
      }
      ItemsCart.Expires = System.DateTime.Now.AddDays(1);
  
      return ItemsCart;
  }
  </code></pre>
  
  <p>Adding item to cookie code :</p>
  
  <pre class="lang-cs prettyprint-override"><code>public IHttpActionResult AddItemToCart(CartItem cartItem)
  {
      var _cookie = new CookiesMaster().CookieWareFromBrowser();
      var Cookieitems = CookiesManagedStrings.decryptingCooki(_cookie.Values[CookiesManagedStrings.Items]);
      if (string.IsNullOrEmpty(Cookieitems.Split('|').SingleOrDefault(s =&gt; s.Contains(cartItem.Id.ToString()))))
  
          _cookie.Values[CookiesManagedStrings.Items] = CookiesManagedStrings.encryptingCooki(Cookieitems + cartItem.Id + "," + cartItem.ProductName.Replace(",", "") + "," + cartItem.IValue + "," + cartItem.Quantity + "|");
      else
      {
          var item = Cookieitems.Split('|').Where(s =&gt; !string.IsNullOrEmpty(s)).SingleOrDefault(si =&gt; si.Contains(cartItem.Id.ToString()));
          var oldQty = int.Parse(item.Substring(item.LastIndexOf(',') + 1));
          var productbalance = _context.storage.Single(p =&gt; p.id== cartItem.Id &amp;&amp; p.M_LOCATOR_ID == M_ProductManagedStrings.ID).FREE_BALANCE;
  
          if (productbalance &gt;= oldQty + cartItem.Quantity)
          {
              var newItem = item.Substring(0, item.LastIndexOf(',') + 1) + (oldQty +cartItem.Quantity);
  
              Cookieitems = string.Join("|", Cookieitems.Split('|').Select(s =&gt; s.Replace(item, newItem)));
              _cookie.Values[CookiesManagedStrings.Items] = CookiesManagedStrings.encryptingCooki(Cookieitems);
          }
          else return BadRequest("Item Qty Exceeds Balance");
      }
      int x = 0;
      var v = CookiesManagedStrings.decryptingCooki(_cookie.Values[CookiesManagedStrings.ItemsCount]);
      if (int.TryParse(v, out x))
      {               
          _cookie.Values[CookiesManagedStrings.ItemsCount] = CookiesManagedStrings.encryptingCooki((int.Parse(v) + 1).ToString());
      }
      else
      {
          _cookie.Values[CookiesManagedStrings.ItemsCount] = CookiesManagedStrings.encryptingCooki(0.ToString());
      }
      HttpContext.Current.Response.Cookies.Remove(CookiesManagedStrings.ItemsCart);
      HttpContext.Current.Response.Cookies.Add(_cookie);
      HttpContext.Current.Response.Cookies.Set(_cookie);
  
      return Ok(_cookie.Values[CookiesManagedStrings.ItemsCount]);
  }
  </code></pre>