Explain Session in ASP.NET Core

There is different concept of Session State in ASP.NET Core. Session data is stored in dictionary on the server and persists data across requests from a browser. A session ID is stored on the client in a cookie. The session ID cookie is sent to server with each request, and the server uses the session ID to fetch the session data.

Set Session

HttpContext.Session.SetString(SessionKeyName, "Rick");
HttpContext.Session.SetInt32(SessionKeyYearsMember, 3);

Get Session

HttpContext.Session.GetString(SessionKeyName);
HttpContext.Session.GetInt32(SessionKeyYearsMember);

results matching ""

    No results matching ""