Posted on: 5/14/2011 4:04:55 AM | Views : 303

Hi;
I'm using WP using Razor and set up a cookie in a page like this:
 
HttpCookie cookie = new HttpCookie("mycookiename"); cookie.Expires = DateTime.Now.AddMinutes(1); cookie.Path = "/"; cookie.Values["sessionId"] = data; cookie.Values["email"] = "email@domain.tld"; Response.Cookies.Add(cookie); Just after that I do a redirect to another page which use a page layout. All other pages depends on that same page layout.
In that page layout I want to update the cookie's expiration time, to keep the cookie alive as long as the user requests any page (besides the logout and default pages of course) in the site. I use this to update the cookie in the page layout:
HttpCookie cookie = Request.Cookies["bvdepqas"]; if (!cookie.Value.IsEmpty()) { // Update the cookie expiration cookie.Expires = DateTime.Now.AddMinutes(Convert.ToInt32(1); Request.Cookies.Set(cookie); } else { ...

Go to the complete details ...