开发者

Cookies, updating the expiration date on each request in mvc

开发者 https://www.devze.com 2023-01-09 09:16 出处:网络
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 enc

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

精彩评论

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