For cookie
what kind of encoding
should be performed (converting a byte array to text) ?
Base64 ?
UrlEncode ?
...
For cookie
what kind of encoding
should be performed (converting a byte array to text) ?
Base64 ?
UrlEncode ?
...
Base64-encoded strings are not valid for URLs or cookies. There are a number of variations on base64 encoding that avoid the forbidden characters. In .NET, you can use HttpServerUtility.UrlTokenEncode() and .UrlTokenDecode().
You don't need any encoding. To prevent user tampering, the simplest solution is to use sessions (which typically uses ASP.NET_SessionId
behind the scenes), rather than making custom cookies.
EDIT: If you really need to store an arbitrary byte array, base 64 will work. But you should explain why you want to do this.
I personally will MD5 encode an ID and store just about everything in a DB or if i can change the db use a GUID instead of a incrementing ID