I am seeing an issue with Kentico where calling URLHelper.Redirect() is logging out the user. This is happening on a registration page. The new Kentico CMS_User object has already been created because if I don't call the Redirect method and just browse to another page, like the user profile page, I stay logged in.
Does anyone have any idea what might cause this method to log the user out?
FYI, I was able to fix this by implementing
System.Web.Security.FormsAuthentication.SetAuthCookie(MembershipContext.AuthenticatedUser.UserName, false);
in the line before I call the Redirect() method.
Redirect()
Hi,
Could you please provide some more info:
Are you using a web farm or do you have load balancer in front of the website? If so you need to set up Redis Cache or SQL Server database session. Any postback or redirect can cause the "authenticated" user to lose their session. By default the URLHelper.Redirect() does NOT log a user out.
URLHelper.Redirect()
This is Kentico 12 portal engine. @Brendan thanks I'll check that out
Before implementing that, I'd suggest looking further into why your cookie is not persisiting. As I stated, the redirect DOES NOT cause a user to log out but a postback could cause issues with persisting the users session if you have a load balancer or a web farm set up. All your line of code is doing now is masking the underlying issue.
Please, sign in to be able to submit a new answer.