Session State

noun

say it: “SESH-un stayt” /ˈsɛʃən steɪt/

Small values the server keeps for one visitor between requests, found again through a session cookie.

What is Session State in ASP.NET Core?

Session State — Small values ASP.NET Core keeps on the server for one visitor between requests, such as their cart id. The browser holds only a cookie with the session's id, and the values themselves stay on the server.

HttpContext.Session.SetString("CartId", "42");
string? cartId = HttpContext.Session.GetString("CartId"); // "42" on the next request too

In a sentence

  • “We keep the visitor's cart id in session state between page visits.”

Level: Journeyman · More ASP.NET Core terms at this level

Updated