Migrating Anonymous User Settings

    // Carry over profile property values from an anonymous to an authenticated state 
    void Profile_MigrateAnonymous(Object sender, ProfileMigrateEventArgs e) {
        ProfileCommon anonProfile 
= Profile.GetProfile(e.AnonymousID);

        
// Merge anonymous shopping cart items to the authenticated shopping cart items
        foreach (CartItemInfo cartItem in anonProfile.ShoppingCart.CartItems)
            Profile.ShoppingCart.Add(cartItem);

        
// Merge anonymous wishlist items to the authenticated wishlist items
        foreach (CartItemInfo cartItem in anonProfile.WishList.CartItems)
            Profile.WishList.Add(cartItem);

        
// Clean up anonymous profile
        ProfileManager.DeleteProfile(e.AnonymousID);
        AnonymousIdentificationModule.ClearAnonymousIdentifier();
        
        
// Save profile
        Profile.Save();
    }
posted @ 2007-08-29 09:23  Vincent Yang  阅读(292)  评论(0编辑  收藏  举报