Class LocalSessionManager
A simple session manager to handle in-memory sessions.
Not for intensive use or for distributed applications.
Implements
Inherited Members
Namespace: EmbedIO.Sessions
Syntax
public class LocalSessionManager : ISessionManager
Constructors
LocalSessionManager()
Initializes a new instance of the LocalSessionManager class with default values for all properties.
Declaration
public LocalSessionManager()
See Also
Fields
DefaultCookieDuration
The default duration for session cookies, i.e.
Declaration
public static readonly TimeSpan DefaultCookieDuration
Field Value
Type | Description |
---|---|
TimeSpan |
DefaultCookieHttpOnly
The default HTTP-only flag for session cookies, i.e. true.
Declaration
public const bool DefaultCookieHttpOnly = true
Field Value
Type | Description |
---|---|
Boolean |
DefaultCookieName
The default name for session cookies, i.e. "__session"
.
Declaration
public const string DefaultCookieName = "__session"
Field Value
Type | Description |
---|---|
String |
DefaultCookiePath
The default path for session cookies, i.e. "/"
.
Declaration
public const string DefaultCookiePath = "/"
Field Value
Type | Description |
---|---|
String |
DefaultPurgeInterval
The default interval between automatic purges of expired and empty sessions, i.e. 30 seconds.
Declaration
public static readonly TimeSpan DefaultPurgeInterval
Field Value
Type | Description |
---|---|
TimeSpan |
DefaultSessionDuration
The default duration for sessions, i.e. 30 minutes.
Declaration
public static readonly TimeSpan DefaultSessionDuration
Field Value
Type | Description |
---|---|
TimeSpan |
Properties
CookieDuration
Gets or sets the duration of session cookies.
Declaration
public TimeSpan CookieDuration { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
See Also
CookieHttpOnly
Gets or sets a value indicating whether session cookies are hidden from Javascript code running on a user agent.
Declaration
public bool CookieHttpOnly { get; set; }
Property Value
Type | Description |
---|---|
Boolean |
See Also
CookieName
Gets or sets the name for session cookies.
Declaration
public string CookieName { get; set; }
Property Value
Type | Description |
---|---|
String |
See Also
CookiePath
Gets or sets the path for session cookies.
Declaration
public string CookiePath { get; set; }
Property Value
Type | Description |
---|---|
String |
See Also
PurgeInterval
Gets or sets the interval between purges of expired sessions.
Declaration
public TimeSpan PurgeInterval { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
See Also
SessionDuration
Gets or sets the duration of newly-created sessions.
Declaration
public TimeSpan SessionDuration { get; set; }
Property Value
Type | Description |
---|---|
TimeSpan |
See Also
Methods
Create(IHttpContext)
Returns the session associated with an IHttpContext. If a session ID can be retrieved for the context and stored session data are available, the returned ISession will contain those data; otherwise, a new session is created and its ID is stored in the response to be retrieved by subsequent requests.
Declaration
public ISession Create(IHttpContext context)
Parameters
Type | Name | Description |
---|---|---|
IHttpContext | context | The HTTP context. |
Returns
Type | Description |
---|---|
ISession | An ISession interface. |
Delete(IHttpContext)
Deletes the session (if any) associated with the specified context.
Declaration
public void Delete(IHttpContext context)
Parameters
Type | Name | Description |
---|---|---|
IHttpContext | context | The HTTP context. |
See Also
OnContextClose(IHttpContext)
Called by a session proxy when a session has been obtained for an IHttpContext and the context is closed, even if the session was subsequently deleted.
This method can be used to save session data to a storage medium.
Declaration
public void OnContextClose(IHttpContext context)
Parameters
Type | Name | Description |
---|---|---|
IHttpContext | context | The IHttpContext for which a session was obtained. |
Start(CancellationToken)
Signals a session manager that the web server is starting.
Declaration
public void Start(CancellationToken cancellationToken)
Parameters
Type | Name | Description |
---|---|---|
CancellationToken | cancellationToken | The cancellation token used to stop the web server. |