开发者

Cookies, updating the expiration date on each request in mvc

I have a fairly simple web app that uses cookies to store some information about the user and to authorize them on each request. When the user first logs into the site a cookie is created and some encrypted information is stored in there, the expiration is set for the current time plus 24 hrs. What I wa开发者_Python百科nt to achieve is that whilst a user is moving through the web app their expiration date is constantly being increased to be 24 hrs from the current time.

What is the best way to do this? Should I be using a attribute on the controller?


You could write a custom action filter that will execute before each action. This filter will read the cookie from the request and set a new cookie with the same name and value but with a new expiration date.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜