Jump to content
Sign in to follow this  
3ddark

Web Server Application Cookie Encoding

Recommended Posts

I am having problems with the Delphi Web Server Application.
I create a cookie and set it as a value

The cookie value comes as ELEKTRON%C4%B0K from the browser.

LCookValues.AddPair('name', 'ELEKTRONİK');
Response.SetCookieField(LCookValues, HOST_ADDR, '/', IncDay(Now, 15), False);

 

When I use it with Base64 encoding, the encoding result is RUxFS1RST07EsEs=

But the result on the browser is RUxFS1RST07EsEs%3D

TNetEncoding.Base64String.Encode('ELEKTRONİK')

 

The place where the characters are broken is in the function below. How can I fix this situation?

procedure TIdHTTPAppResponse.MoveCookiesAndCustomHeaders;
.....
begin
...
LDestCookie.Value := DoHTTPEncode(LSrcCookie.Value);
...
end;

When I test Base64 encode/decode online from any site, the extra characters give incorrect results.

 

When I want to use this cookie in other requests, I use it as follows.

TNetEncoding.Base64String.Decode(Request.CookieFields.Values['name'])

As a result, the information I receive is ELEKTRONİK7 This is not my correct information.

Share this post


Link to post
TNetEncoding.Base64String.Decode(TNetEncoding.URL.Decode(Request.CookieFields.Values['name']))

Use like this working. But constantly converting things is a waste of time.

Where am I going wrong? There must be an easier way.

Other web tools do not have any of these problems. We can solve all web processes very easily.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×