How to store an object in a cookie?

后端 未结 10 1824
名媛妹妹
名媛妹妹 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:26

    you could encrypt such a cookie as well. The contents (json/xml/etc) would be a bit safer then. Server-side caching as Marc suggests is probably better.

    Tradeoff: increased traffic on the wire (cookies are passed back and forth) Vs larger server-side memory footprint and / or secondardy storage.

    btw: don't forget that binary can be encoded to text if you really need that.

    http://www.codeproject.com/KB/security/TextCoDec.aspx

提交回复
热议问题