title: access cookie in _Layout.cshtml in ASP.NET Core
body: <p>I'm trying to store an authentication-key into my cookies when login succeeded:</p>
  
  <pre><code>HttpContext.Response.Cookies.Append("Bearer", accessToken, cookieMonsterOptions);
  </code></pre>
  
  <p>So in the controller-class this works. I can easily create and read my cookies. 
  But now I want to check and, if it exists, read the value of a cookie in my <code>_Layout.cshtml</code> and show the name of the logged in user - or the link to login.
  But how can I read my cookies in the partial <code>_Layout.cshtml</code>?</p>
  
  <pre><code>string value = HttpContext.Request.Cookies.Get("Bearer");
  </code></pre>
  
  <p>doesn't work. It tries to add either <code>System.Web</code> to my usings or says HttpContext is static and needs a reference to access <code>Request</code>.</p>
  
  <p>Any suggestions or ideas?</p>