How to store an object in a cookie?

后端 未结 10 1849
名媛妹妹
名媛妹妹 2020-12-15 08:49

While this is possible in C#: (User is a L2S class in this instance)

User user = // function to get user
Session[\"User\"] = user;

why this

10条回答
  •  被撕碎了的回忆
    2020-12-15 09:38

    System.Collections.Specialized.NameValueCollection cookiecoll = new System.Collections.Specialized.NameValueCollection();
    
                cookiecoll.Add(bizID.ToString(), rate.ToString());
    
    
            HttpCookie cookielist = new HttpCookie("MyListOfCookies");
            cookielist.Values.Add(cookiecoll);
            HttpContext.Current.Response.Cookies.Add(cookielist);
    

提交回复
热议问题