title: Why doesn't i get the session when i fetch it in react?
body: <p>When i paste the endpoint int the browser url and save and fetch the session it works.</p>
  <p>But when i try it with react fetch like this:</p>
  <pre><code>fetch(`https://localhost:44369/api/users/save-to-session?userId=${userId}`, {
    method: &quot;GET&quot;,
    mode: &quot;cors&quot;,
    credentials: &quot;include&quot;,
  }).then(() =&gt; {
    fetch(`https://localhost:44369/api/users/fetch-from-session`, {
      method: &quot;GET&quot;,
      mode: &quot;cors&quot;,
      credentials: &quot;include&quot;,
    })
      .then(function (body) {
        return body.text();
      })
      .then((response) =&gt; {
        console.log(response);
      });
  });
  </code></pre>
  <p>I get null back.</p>
  <p>This is the asp.net core web api endpoint</p>
  <pre><code>    [HttpGet]
      [Route(&quot;save-to-session&quot;)]
      public IActionResult SaveToSession(string userId)
      {
          HttpContext.Session.SetString(&quot;user&quot;, userId);
          return Content(userId);
      }
  
      [HttpGet]
      [Route(&quot;fetch-from-session&quot;)]
      public IActionResult FetchFromSession()
      {
          string name = HttpContext.Session.GetString(&quot;user&quot;);
          return Ok(name);
      }
  </code></pre>
  <p>It could be because of CORS?
  This is in my startup file:</p>
  <pre><code>    services.AddCors();
      services.AddMvc();
  
  services.AddSession(options =&gt; {
                  options.IdleTimeout = TimeSpan.FromMinutes(60);
                  options.Cookie.HttpOnly = false;
                  options.Cookie.IsEssential = true;
              });
  
  
  
     app.UseCors(options =&gt; options.WithOrigins(&quot;http://localhost:3000&quot;)
                 .AllowAnyMethod()
                 .AllowAnyHeader()
                 .AllowCredentials());
  </code></pre>