实现Profile购物车的匿名用户迁移
在Global.asax文件中,增加一個方法:
? protected void Profile_MigrateAnonymous(Object s, ProfileMigrateEventArgs e)
??? {
??????? ProfileCommon anonProfile = Profile.GetProfile(e.AnonymousID);
???????
??????? //遷移Profile用戶名
??????? //Profile.userName = anonProfile.userName;
???????
??????? //遷移購物車
??????? //Profile.ShoppingCart = anonProfile.ShoppingCart;
???????
??????? IEnumerator ie = anonProfile.ShoppingCart.CartItems.GetEnumerator();
??????? while (ie.MoveNext())
??????? {
??????????? Profile.ShoppingCart.AddCartItem((CartItem)ie.Current);
??????? }?????????????
??????
??????? //清除匿名COOKIE,不然每次請求頁面都執(zhí)行此事件
??????? AnonymousIdentificationModule.ClearAnonymousIdentifier();
??????? // Response.Cookies["UserName"].Expires = DateTime.Now.AddDays(-1);
???????
??????? //匿名COOKIE標識已重置,下次匿名訪問將創(chuàng)建新的profile數(shù)據(jù)條,原來的匿名profile數(shù)據(jù)條已無意義
??????? ProfileManager.DeleteProfile(e.AnonymousID);??????
??? }
?
?
轉(zhuǎn)載于:https://www.cnblogs.com/zhangzgl/archive/2009/06/15/1503647.html
總結(jié)
以上是生活随笔為你收集整理的实现Profile购物车的匿名用户迁移的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: matplotlib+seaborn图形
- 下一篇: LOLs11寒冰出什么装备 艾希出羊刀还