How many types of Cookies in ASP.NET?

Cookies are small pieces of information stored in the client computer . It contains information the Web application can read whenever the user visits the site. They are limited to 4K in size.

There are two type of cookies in Asp.Net:

  1. Persistent cookies
  2. Non-persistent cookies

Persistent Cookies

Persistent cookies, also known as durable cookies, are stored on the user's device even after the browser session ends. These cookies have an expiration date set in the future, and they remain on the user's device until either the expiration date is reached or the user manually deletes them. Persistent cookies are useful for scenarios where you want to remember certain user preferences or maintain session information across multiple visits.

Non-Persistent Cookies

Non-persistent cookies, also known as session cookies, are temporary cookies that are only stored in the user's browser memory for the duration of the browsing session. These cookies are deleted as soon as the user closes the browser. Non-persistent cookies are commonly used to store transient data related to the current session, such as session identifiers or user authentication tokens.

Conclusion

Both types of cookies can be utilized in ASP.NET applications to store and retrieve information on the client-side, allowing for personalized user experiences and maintaining state across multiple requests.