6

In MVC5, I used to use my session variables like this from System.Web

PayPalHandler.ExecutePayment(
    Convert.ToString(Session["paymentId"]), 
    Convert.ToString(Session["payerId"]));

In ASP5/MVC6, this is no longer an option as System.Web does not exist. What is the proper equivalent way of using session variables in the new framework? Documentation is still very scarce.

DavidG
  • 113,891
  • 12
  • 217
  • 223
Corey Chase
  • 87
  • 1
  • 5

1 Answers1

3

you need to install Nuget package

Microsoft.AspNet.Session

and use it using Context

Context.Session.SetString("Name", "My Name"); //Set
var name = Context.Session.GetString("Name");//Get

Good explanation can be found at http://www.mikesdotnetting.com/article/270/sessions-in-asp-net-5

Thakur
  • 559
  • 6
  • 15