Document expiry in Couchbase SessionState Provider with Couchbased bucket

Hi everybody,

My problem is even i set Session timeout to 40 minutes in web.config as you see below my documents are stored like infinite;

<sessionState customProvider="couchbase-session" mode="Custom" **_timeout="40"_**>
    <add name="couchbase-session" type="Couchbase.AspNet.SessionState.CouchbaseSessionStateProvider, Couchbase.AspNet" bucket="xxxx" maxRetryCount="6" />

How can i fix this for my documents to live 40 minutes or what i set.

Thanks in advance.

Couchbase Version: 4.5.0-2601 Enterprise Edition
My Bucket Type is Couchbase

@f.saki -

From a cursory look, it doesn’t appear that the session that the ASP.NET Session provider allows timeout in configuration. The best thing to do would be to create a Jira ticket and it will be fixed/added in a later release. You can also provide a pull request if you feel inclined to contribute and you feel like you can provide a fix.


Jeff thanks for info.
I will use bucket for only Session so;
Can we set a default expiry for a bucket from Couchbase console?

I don’t believe you can through the management console. The TTL is set per item when its inserted or updated by an SDK.

Hmm, so do you have any idea about how can we handle Session timeout for Couchbase SessionState?

Hi @f.saki

Unfortunately the Couchbase SessionState Provider currently doesn’t support the timeout configuration property.

The change should be fairly straight forward and loosely covered by:

  • Checking for the timeout key in the config collection during Initialize in CouchbaseSessionStateProvider
  • Passing in the Timeout to SaveData in SessionStateItem

If you would like to make the change yourself and create a PR that would great. If not, we’ll try to get to it when we can.


1 Like


I added a Jira ticket to track this:

Ok i will try to develope this ability to project. But i don’t know if I can update project at github.

Sorry to bring up this rather old topic.
I use Couchbase ASP.NET Integration 2.0.0-beta4 and Couchbase SDK 2.2.8.
The web.config looks like that of the thread opener, but in contrast to him I don’t see an infinite expiration property of session documents, but an expiration of 20 min in the future, and this property is set when the document is created or get’s accessed.
My questions: Where are these 20 min defined? If it’s not hardcoded, maybe in a config file? You see, I am looking for a way to change this value, even if it can’t be set in the management console.

@Hamster -

20 mins is the default value for the Timeout property for the ASP.NET Session Provider:

A couple of things to note:

  • 2.0.0-beta4 should be updated to 2.0.0 GA - note there may be some upgrade challenges, but beta is no longer supported.
  • We have a 3.0 for .NET Core branch which will be a beta soon:
  • We haven’t yet decided if we are going to release a 3.0 for .NET Full - if we do it would be a re-write of the 2.0 API’s.