title: Asp.Net Core Razor pages, session variable is not accessible from other views/razor models
body: <p>I am saving session variable in login page,</p>
  
  <pre><code>Guid sessionId = Guid.NewGuid();
  
  HttpContext.Session.SetString("sessionId",sessionId.ToString());
  Response.Cookies.Append("sessionId", sessionId.ToString());
  </code></pre>
  
  <p>Now I access this variable like this:</p>
  
  <pre><code>string sessionId = Request.Cookies["sessionId"];            
  
  if (!String.IsNullOrEmpty(sessionId) &amp;&amp; sessionId.Equals(HttpContext.Session.GetString("sessionId")))
  {
      return RedirectToPage("/LoggedIn/Index");
  }
  
  return Page();
  </code></pre>
  
  <p>This code I use on the same razor page (login page) in which session Id is declared, however if I use the above code in any other razor view page, I cannot access this session variable. It is only accessible on the same page it was saved.</p>
  
  <p>What can I possibly be doing wrong ?</p>