Using Cookies in ASP.NET Core apps
cookies Using Cookies in ASP.NET Core apps What are cookies Cookies are small data files sent by websites that are stored in the browser Cookies are sent every time a request is sent to the server Cookies are useful for persisting user login, tracking user activity to create personalized experiences, etc. Demo We will create a simple TODO list web app using ASP.NET Core The server will save the todo list in the user’s browser using cookies Set cookie A server can set a cookie and send it in the response to the client’s browser The browser will update the cookie Each cookie has a unique key In our demo application, the server sets a cookie to store todos in the client’s browser using Response.Cookies.Append Response . Cookies . Append ( nameof ( Todo ) , JsonSerializer . Serialize ( todos ) ) ; Retrieve Cookie data Client Browser sends cookies to the server in every request The cookie data can be retrieved using Request.Cookies In our dem...