Featured

How to work with cookies in ASP.NET 6

Last modified: April 09, 2022

Cookie is piece of data stored in users' browser.

1. Create a Cookie

Response.Cookies.Append("darkTheme", "yes");

2. Read a Cookie

var cookie = Request.Cookies["darkTheme"];

2. Update a Cookie

Response.Cookies.Append("darkTheme", "No");

3. Delete a Cookie

Response.Cookies.Delete("darkTheme");