asp.net cookies, authentication and session timeouts

后端 未结 5 634
天命终不由人
天命终不由人 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:36

    My preferred method is to use session like cache. that is, try to read from session, if the value is there then return it, if it's not, read it from persistence store (database, etc), put it in session and return it.

    To simplify this, create a class, add a property for each variable in session, and store an instance of the class in session. Then create a static method to get an instance of the class. I'll add an example later if I could.

提交回复
热议问题