Legend Class Struct Enum Interface Delegate | Constructor Method Property Event Field |
| Abstract class: RT.Servers.SessionSummary
Provides functionality to track user sessions in HTTP requests using cookies. See remarks for usage guidelines. Remarks
Intended use is as follows: -
Declare a class containing one or more fields which constitute your session data.
-
Derive that class from Session, FileSession, or your own specialization of
either.
You can now augment any HTTP request handler that looks like this:
req => { /* code to handle request, no session support */ }
by changing it into this:
req => Session.EnableAutomatic<TSession>(req, session => {
/* code to handle request with session variable available */
})
(replace TSession with the name of your derived class; see Session.EnableAutomatic<TSession>(HttpRequest, Func<TSession, HttpResponse>) or Session.EnableManual<TSession>(HttpRequest, Func<TSession, HttpResponse>)). -
Within your request handler, you can make arbitrary changes to the session object, which will be persisted
automatically.
-
If you use Session.EnableManual<TSession>(HttpRequest, Func<TSession, HttpResponse>), Session.SessionModified must be set to
true whenever
any value in the session object is changed. -
If you use Session.EnableAutomatic<TSession>(HttpRequest, Func<TSession, HttpResponse>), the session
object must implement ISessionEquatable<TSession>. In this case, modifications to the
session object are detected by taking a clone of the session object, then running the request handler, and
then comparing the two.
-
You can set Session.Action if you want the session reverted or deleted.
Instance methodsStatic methodsInstance propertiesSessionAction | | Controls what happens to the session data when the request handler returns. | bool | |
True if a new session was created, or any of the cookie parameters were modified (such as Session.CookieExpires). | string | | Contains the session ID, which is also the cookie value. | bool | |
True if a new session was created, or any of the session variables were modified. Derived classes should set
this to true whenever a session variable is modified. Set this to false to discard all session changes
(otherwise they will be saved upon session Session.CleanUp(HttpResponse, bool)). |
|