asp.net cookies, authentication and session timeouts

后端 未结 5 638
天命终不由人
天命终不由人 2020-11-29 19:04

I have an asp.net website that uses forms authentication. There are a few things I keep in sessions like username, userID, email, etc.

I allow the user to stay logge

5条回答
  •  旧巷少年郎
    2020-11-29 19:43

    Personally, I would keep the 20 minute default and add a "keep alive" functionality to your site. Make a simple javascript that polls, say heartbeat.aspx, every 5 minutes to keep the session alive. This will extend the session and authentication without keeping crazy authentication tokens.

    There are a few examples (bad in my opinion) of how to do this. I ended up using something based on AjaxLines's session timeout prevention. Instead of using the ajax library, though, I simply used an xhtml request directly. Nothing is really needed more than a timed javascript call to a GET on the heartbeat page.

提交回复
热议问题