Write the code that creates a cookie containing the user name R4R and the current date to the user computer. Set the cookie to remain on the user computer for 30 days?
Code: HttpCookie cookUserInfo = new HttpCookie("UserInfo"); CookUserInfo["Name"] = "R4R"; CookUserInfo["Time"] = DateTime.Now.ToString(); cookUserInfo.Expires = DateTime.Now.AddDays(30); Response.Cookies.Add(cookUserInfo); Description: "HttpCookie" :The HttpCookie class is under System.Web namespace. "CookUserInfo" :is the object of class HttpCookie "Expires": is the property that sets the duration,when cookie expire.
Posted By:
Name:Rajesh Kr
URL: Write the code that creates a cookie containing the user name R4R and the current date to the user computer. Set the cookie to remain on the user computer for 30 days?