title: How to get cookie value from response using angular
body: <p>I currently work on a project using .Net Core 3.1 for server and angular for the client.</p>
  <p>I`m storing my values in a session using .net core session, now when I send a post request using postman I can see the key the response sent me back under Cookies tab (the name is .AspNetCore.Session), also when I send the request from my client I see in the network tab the desirable response under Response Headers but when I try to return it as an Observable it returns as null. <a href="https://i.stack.imgur.com/yaWN8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yaWN8.png" alt="enter image description here" /></a></p>
  <p>Now my question is how can I access that set-cookie from the client? I tried some approaches and none was good.</p>
  <p>my current startup.cs ConfigureServices:</p>
  <pre><code>        {
  
              services.AddControllers().AddNewtonsoftJson(options =&gt; options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore);
              services.AddCors();
          
              services.AddDistributedMemoryCache();
  
              services.AddControllers().AddJsonOptions(options =&gt;
              {
                  options.JsonSerializerOptions.IgnoreNullValues = true;
              });
              
              services.AddHttpContextAccessor();
              services.AddScoped&lt;IFavoriteRepository, FavoriteRepository&gt;();
              services.AddSession(options =&gt;
              {
                  options.IdleTimeout = TimeSpan.FromSeconds(1800);
                  options.Cookie.HttpOnly = true;
                  options.Cookie.IsEssential = true;
              });
  
          }
  </code></pre>
  <p>session methods</p>
  <pre><code>public void AddRepo(Repository repo)
          {
  
              var repository = new Repository() { RepoName = repo.RepoName, AvatarUrl = repo.AvatarUrl };
              var json = JsonConvert.SerializeObject(repository);
               _httpContextAccessor.HttpContext.Session.SetString(&quot;SessionUser&quot;, json);
              
          }
  
          public Repository GetRepo()
          {
               var sessionUser = JsonConvert.DeserializeObject&lt;Repository&gt;(_httpContextAccessor.HttpContext.Session.GetString(&quot;SessionUser&quot;));
              return sessionUser;
          }
  </code></pre>
  <p>controller:</p>
  <pre><code> [HttpPost]
          public IActionResult AddFavorite(Repository repo)
          {
              _repo.AddRepo(repo);
              return Ok();
          }
  </code></pre>
  <p>angular service</p>
  <pre><code>saveRepo(repo: Repository) {
  
      return this.http.post&lt;any&gt;(this.baseUrl + &quot;Repositories&quot;, repo ,{ observe: 'response'})
        .pipe(
          map(response =&gt; {
            return response.headers;
          })).subscribe(data =&gt; console.log(data));
   }
  </code></pre>