taglius
taglius

Reputation: 1247

Session expiry value starts off ok, then changes to default

I have a special case when I'm trying to set my session to expire in 30 minutes. My code that saves the session looks like below. When I set a breakpoint here, the value of the variable is what I want (30min). When I step over the SaveSession line, the row in my cache has an ExpiryDate of 30 minutes away. However, something is changing the ExpiryDate in the cache back to the default of 2 weeks and I'm not sure what that could be. This line is the only .SaveSession in my entire service.

sessionExpiry = sessionExpiry ?? ServiceStack.SessionFeature.DefaultSessionExpiry;
authService.SaveSession(session, sessionExpiry);

Upvotes: 1

Views: 83

Answers (1)

mythz
mythz

Reputation: 143369

You can override AppHost.OnSaveSession() to handle everytime the Users Session is saved, e.g:

public override void OnSaveSession(IRequest req, IAuthSession session, TimeSpan? expiresIn=null)
{
    return base.OnSaveSession(req, session, TimeSpan.FromMinutes(30));
}

Upvotes: 2

Related Questions