Cache VS Session VS cookies?

前端 未结 8 749
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-02 04:09

What are the do\'s and don\'ts about Cache VS Session VS Cookies?

For example:
I\'m using Session variables a lot and sometimes have problems in a booking-applic

8条回答
  •  -上瘾入骨i
    2020-12-02 04:39

    State management is a critical thing to master when coming to Web world from a desktop application perspective.

    • Session is used to store per-user information for the current Web session on the server. It supports using a database server as the back-end store.
    • Cookie should be used to store per-user information for the current Web session or persistent information on the client, therefore client has control over the contents of a cookie.
    • Cache object is shared between users in a single application. Its primary purpose is to cache data from a data store and should not be used as a primary storage. It supports automatic invalidation features.
    • Application object is shared between users to store application-wide state and should be used accordingly.

    If your application is used by a number of unauthenticated users, I suggest you store the data in a cookie. If it requires authentication, you can either store the data in the DB manually or use ASP.NET profile management features.

提交回复
热议问题