Set PersonalizedData on login?

I have a custom login screen, containing some fields which I wish to save as PersonalizedData. However, I want to do this immediately after authenticating, which means I don't have access to the user data who has just logged in. I'm using the following code to try and access this user: string url = HandleLogin(); if (url != null) { IPrincipal principal; principal = AuthenticationProvider.Authenticate(this, Username.Text, Password.Text); HttpContext.Current.User = principal; // try and set current user in code CurrentUser.UserData["MyField"] = MyField.Text; CurrentUser.UserData.Save(); // this doesn't save PersonalizedData.Load(Username.Text); // try and populate PersonalizedData PersonalizedData.Current["MyField"] = MyField.Text; PersonalizedData.Current.Save(); // this doesn't save either Response.Redirect(url); // normal login redirect } As you can see from my comments, the two methods I've tried to set custom data for the user don't work. Can anybody help? Thanks, /\dam
Jun 14, 2007 10:44
Hi Adam! The following should work: if( UnifiedPrincipal.Current.Identity.IsAuthenticated ) { PersonalizedData pd = UnifiedPrincipal.Current.UserData; pd["ShoeSize"] = "8.5"; pd["FavouritePet"] = "Cat"; pd.Save(): } Regards, Johan Olofsson
Jun 14, 2007 11:16
That works a treat, many thanks! /\dam
Jun 14, 2007 12:26
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.