GetSession
is better named GetOrCreateSession
as it will either Get a Typed Session or create a new one if it doesn't exist. It also stores the instance of the Session in HTTP Request Context where if reload:false
will return the local instance when it exists:
IAuthSession session = GetSession(reload:false);
IAuthSession session = GetSession(reload:true);
If reload:true
it will always retrieve the Session from the underlying ICacheClient
.
SessionAs<T>
always gets the Session from the ICacheClient
and returns an empty instance if it doesn't exist. It also returns a typed version of your Custom AuthUserSession
:
CustomUserSession session = SessionAs<CustomUserSession>();