How can I simply update the cookie expiration on every page request without any effect on its value?
'update the User cookie expiration time on every page load Dim cookieName As String = ConfigKeys.UserCookieName Dim cookieExpr As String = ConfigKeys.CookieExpiration.ToString '--get the cookies from request object Dim userCookie As HttpCookie = HttpContext.Current.Request.Cookies(cookieName.ToUpper()) '--set the expiry date userCookie.Expires = DateTime.Now.AddMinutes(Integer.Parse(cookieExpr)) '--add the updated cookies back to Response object HttpContext.Current.Response.Cookies.Add(userCookie)
HttpContext.Current.Response.Cookies["MyCookie"].Expires = DateTime.Now.AddDays(1)
Or set the maximum value and forget about expiration:
HttpContext.Current.Response.Cookies["MyCookie"].Expires = DateTime.MaxValue
Source: https://habr.com/ru/post/1711995/More articles:First create a database script and create a database using SQL Server Management Studio, and then create a script - sqlfailed to add a new row using datagridview using c # in winforms - c #Sending binary stream via SOAP - c #Software injection of properties with Microsoft Unity - inversion-of-controlJQuery Tools tab not showing in IE7 - jqueryUse nant to create a custom task - nantWhat should a .NET developer know about MSBuild? - asp.netHow to add fade-in / fade-out animation based on the value of the ViewModel property? - triggersAre any PIC microcontroller MP3 encoder libraries supported? - embeddedWriteConsole () weird characters? - c ++All Articles