var session = HttpContext.Session; session.SetString("UserName", "John"); string userName = session.GetString("UserName");
var session = HttpContext.Session; session.SetInt32("Count", 5); int count = session.GetInt32("Count");In this example, we are setting and getting an integer value from the session using ISessionWrapper. The SetInt32 method is used to set the value of "Count" in the session. These examples belong to the Microsoft.AspNetCore.Http package library.