Interfaces

Project

Session

NuGet packageOwin.Framework.Session
GitHub sourceOwinFramework.Session

Home |  Readme

Contains a few alternate implementations of ISession that your application can choose from

This middleware provides session for your website or webservice using the ICache interface implementation registered with IoC.

Session is a dictionary of name/value pairs that is unique to each visitor to the website. The user is identified by storing a cookie on thier browser.

You typically want to provide an ICache implementation that provides a consistent view across servers so that you do not need sticky sessions, but you can also use an in-memory cache and sticky sessions if you want.

Adding this middleware to the Owin pipeline

 builder.Register(ninject.Get<OwinFramework.Session.CacheSessionMiddleware>())
    .As("Session")
    .ConfigureWith(config, "/owinFramework/middleware/session");    
The assumes that you are using Ninject as your IoC container, and followed the getting started walkthrough. If this is not the case then you will need to adjust the code to work in your application.

Default Configuration

The configuration below is the configuration you will get by default if you do not provide a configuration for this middleware.

{
   "owinFramework": {
      "middleware": {
         "session": {
            "cacheCategory": "session",
            "sessionDuration": "00:20:00",
            "cookieName": "owin-framework-sid",
            "cookieDomainName": ""
         }
      }
   }
}

Configuration notes

  • The cache category is passed to the ICache interface so that it can implement business logic that is specific to session storage.
  • You should set the cookie domain name to your root domain if you want to share session across multiple services that are in sub-domains. For example if you have services at https://service1.mycompany.com/ and https://service2.mycompany.com/ then you should set the cookieDomainName to mycompany.com