How to store custom data in ASP.NET Membership Cookie

前端 未结 2 1092
花落未央
花落未央 2021-01-03 07:27

Can anyone give me an example (or point me in the right direction) on how to store custom data in an ASP.NET Membership cookie?

I need to add some custom properties

2条回答
  •  误落风尘
    2021-01-03 08:02

    Depending on the scenario, using a separate cookie might be a viable option, but in my opinion is sub optimal for several reasons including the simple fact that you have to manage multiple cookies as well as managing the lifetime of the cookie.

    The most reliable strategy for incorporating custom information into your forms ticket is to leverage the userData field of the ticket. That is exactly what it is there for.

    You can easily store custom data in the userData field of the ticket.

    There are a few concerns to be aware of regarding the size of the data to be stored in the ticket that are explained here

    And here is a small class that can help in the task of storing custom data in your forms ticket.

提交回复
热议问题