HttpCookie cookie = new HttpCookie("myCookie"); cookie.Value = "Hello, world!"; cookie.Expires = DateTime.Now.AddDays(7); string cookieString = cookie.ToString();In this example, we create a new HttpCookie object with the name "myCookie", set its value to "Hello, world!", and set its expiration date to one week from now. We then call the ToString method to get a string representation of the cookie. Package/library: The HttpCookie class is part of the System.Web namespace, which is included in the .NET Framework.