gatsby0121
-
7/4/2011 5:49:02 AM
RE:CookieHelper.ChangeCookieExpiration from static method
Turns out that issue was something else which I fixed. But for some reason when I call the method, it runs, but when I close the browser and go back to the page, I'm logged out.
This is the code I'm using:
// Set view mode to live site after login to prevent bar with "Close preview mode" CMSContext.ViewMode = CMS.PortalEngine.ViewModeEnum.LiveSite;
// Ensure response cookie CookieHelper.EnsureResponseCookie(FormsAuthentication.FormsCookieName);
if (Membership.ValidateUser(userEmail, customerPwd)) { FormsAuthentication.SetAuthCookie(userEmail, false); CMS.GlobalHelper.RequestStockHelper.Remove("CurrentUser"); CMS.GlobalHelper.RequestStockHelper.Add("CurrentUser", new CMS.CMSHelper.CurrentUserInfo(ui, true)); }
// Set cookie expiration if (RememberMeSet) { CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddYears(1), false); } else { FormsAuthentication formAuth = new FormsAuthentication(); // Extend the expiration of the authentication cookie if required if (!UserInfoProvider.UseSessionCookies && (HttpContext.Current != null) && (HttpContext.Current.Session != null)) { CookieHelper.ChangeCookieExpiration(FormsAuthentication.FormsCookieName, DateTime.Now.AddMinutes(HttpContext.Current.Session.Timeout), false); } }
|