2020-02-28 11:15:25 +01:00
|
|
|
using System.Web;
|
2020-03-25 16:52:42 +11:00
|
|
|
using Umbraco.Net;
|
2020-02-28 11:15:25 +01:00
|
|
|
|
|
|
|
|
namespace Umbraco.Web.AspNet
|
|
|
|
|
{
|
|
|
|
|
public class AspNetSessionManager: ISessionManager, ISessionIdResolver
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public AspNetSessionManager()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-01 20:00:27 +02:00
|
|
|
public string GetSessionValue(string sessionName)
|
2020-02-28 11:15:25 +01:00
|
|
|
{
|
2020-04-01 20:00:27 +02:00
|
|
|
return HttpContext.Current?.Session[sessionName]?.ToString();
|
2020-02-28 11:15:25 +01:00
|
|
|
}
|
|
|
|
|
|
2020-04-01 20:00:27 +02:00
|
|
|
public void SetSessionValue(string sessionName, string value)
|
2020-02-28 11:15:25 +01:00
|
|
|
{
|
2020-04-01 20:00:27 +02:00
|
|
|
var httpContext = HttpContext.Current;
|
|
|
|
|
if (httpContext is null) return;
|
2020-02-28 11:15:25 +01:00
|
|
|
HttpContext.Current.Session[sessionName] = value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public string SessionId => HttpContext.Current?.Session?.SessionID;
|
|
|
|
|
}
|
|
|
|
|
}
|