Paul Lucas
Paul Lucas

Reputation: 1615

Safe way to encode a cookie value in c#

When storing a value in a cookie using C#, what is the best way to encode (or escape) the value so that it can be retrieved and decoded/unescaped reliably?

I'm not talking about encryption.

Upvotes: 13

Views: 13067

Answers (1)

Tom Cabanski
Tom Cabanski

Reputation: 8018

Well, the safest thing to do is use UrlEncoding (use HttpServerUtility.UrlEncode).

Upvotes: 17

Related Questions