Hello all,
This question is sort of related to a previous posting by me here: http://www.imiscommunity.com/redirect_to_billing_page_after_auto_login_forcing_re_login
I have captured when a user has paid for their membership, and have updated their status (CustomerTypeCode) to a Member.
The problem is, the user cannot access any members only content immediately. They must first logout, then log back in. Only then can they access members only content.
I'm not sure how to get around this problem. I've tried a few things, including programmatically logging them out and logging them back in, but nothing seems to work.
The code I used to programmatically re-login the user is below (basically the same code that solved my earlier problem). Perhaps there's something still not being set identifying the user as a member? (This code is run right after updating the contact's CustomerTypeCode and saving it).
[code]
string contactLogin = contact.UserSecurity.WebLoginId;
using (Asi.Security.SecurityContext.Impersonate(contactLogin))
{
FormsAuthentication.SignOut();
Asi.Security.SecurityContext.LogonByUserId(contactLogin);
Session["LoginUser"] = CContactUser.LoginByWebLogin(contactLogin);
FormsAuthentication.SetAuthCookie(Asi.Security.AppPrincipal.CurrentIdentity.Name, false);
}
[/code]
Any help is greatly appreciated.
Thanks,
Colin
Hi, I think you need to
Hi,
using (Asi.Security.SecurityContext.Impersonate(contactLogin))
{
FormsAuthentication.SignOut();
Asi.Security.SecurityContext.LogonByUserId(contactLogin);
Session["LoginUser"] = CContactUser.LoginByWebLogin(contactLogin);
FormsAuthentication.SetAuthCookie(Asi.Security.AppPrincipal.CurrentIdentity.Name, false);
}