Session expiry value starts off ok, then changes to default

孤街醉人 提交于 2019-12-11 06:39:48

问题


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);

回答1:


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));
}


来源:https://stackoverflow.com/questions/37148028/session-expiry-value-starts-off-ok-then-changes-to-default

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!