Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Class: RT.Servers.SimpleSession

Summary

Provides functionality to track a session ID in HTTP requests using cookies.

Remarks

This class only retrieves session IDs from the session cookie and does not handle mapping IDs to session data. It also does not automatically create a new session if the HTTP response did not contain a session cookie.

Constructors

SimpleSession(string cookieName = "SessionID")
Constructs a new instance.

Static methods

stringReturns a random string of 32 characters useful as a session ID.

Instance methods

void Specifies that the session cookie should be deleted by the Handle method. Its value is false initially and right after calling Handle().
HttpResponse
Handle(HttpRequest req, Func<HttpResponse> handler)
Retrieves the session ID from the session cookie (specified by the cookie name) from the given HttpRequest and calls the handler function. A session cookie is added to the HTTP response returned by the handler only if either SimpleSession.DeleteSession() or SimpleSession.NewSession(string, DateTime?, string) have been called (possibly by the handler). Before the possibly augmented HTTP response is returned, the status of DeleteSession and NewSession is reset.
void
NewSession(string sessionID, DateTime? cookieExpiry, string cookiePath = "/")
Specifies that a new session should be created. (The SimpleSession.Handle(HttpRequest, Func<HttpResponse>) method adds the relevant cookie to the HTTP response.) It also sets the current SessionID to the specified ID.

Instance properties

DateTime?The expiry date of the retrieved session cookie. If null, the session expires when the client's browser closes.
stringThe name of the cookie that contains the session ID.
stringThe path of the retrieved session cookie.
stringThe session ID retrieved from the session cookie.