Cookies special characters.

  • Thread starter Thread starter helveticus
  • Start date Start date
H

helveticus

Is it possible to write special html characters in a cookie? I'm
having difficulties reading these characters back out of the cookie:
the string representation is garbled. Strings with special chars are
rendered fine on my local machine but not with remote US server.

Using ISO 8859-1 characters codes such as é or é yield no
improvement. I've also tried UTF8 encoding to no avail as shown below.
TIA for any hints.

Read/write cookie functions (simplified) :

Private Sub ReadCookie()
...
Request.ContentEncoding = System.Text.Encoding.UTF8
Dim strCk As String = CStr(Request.Cookies(cok)(cpageName))
...
End Sub

Private Sub WriteCookie()
...
Dim strCk As String = String.Format("{0}", Me.hdr.InnerHtml)
Response.ContentEncoding = Encoding.UTF8
...
End Sub
 
After some experimenting, it seems that Server.UrlEncode and
Server.UrlDecode do the trick.
 
Back
Top