EldoS | Feel safer!

Software components for data protection, secure storage and transfer

How to add cookies when using the cookiemanager

Also by EldoS: MsgConnect
Cross-platform protocol-independent communication framework for building peer-to-peer and client-server applications and middleware components.
#33809
Posted: 06/27/2015 10:04:02
by Walter Schrabmair (Priority Standard support level)
Joined: 05/03/2013
Posts: 150

HI,
I use the cookiemanager, which works fine.
BUt now I want to add 4 cookies, which the cookiemanager do not add them, as they are generated by Javascript. How Can I add the 4 cookies in addition to the cookies the cookiemanager creates.

I know I can disable the cookiemanager and do all the cookies myself. But is there a way to use the manager and add individually cookies too?

I hope I could express what I want to do. Thanks
#33810
Posted: 06/27/2015 10:57:59
by Eugene Mayevski (EldoS Corp.)

Of course, it is possible to add cookies in your code, as they are added in SecureBlackbox code.

The simplest way is to use TElCookieManager.SetCookiesForURL() method. This will work when you have cookies received from the server or otherwise formatted as valid cookies.

Alternatively you can use the following sequence of calls:

Code
Domain := TElCookieDomain.Create;
Domain.Domain := 'mydomain.com';
TElCookieManager.AddDomain(Domain);
Cookie := TElCookie.Create;
// populate cookie here
Domain.Add(Cookie);


Sincerely yours
Eugene Mayevski
#33811
Posted: 06/27/2015 12:18:21
by Walter Schrabmair (Priority Standard support level)
Joined: 05/03/2013
Posts: 150

Thanks, I have added my cookies as TSTringlist to the TElCookieManager.SetCookiesForURL() method.

But when I control it via fiddler, I discovered that the value of the added cookies are all between ". Is that correct?

Code
Cookie:   done by adding
xmlHttpRequest="true";
utt="b7ac8bc0fcbc41a109ec14911f12df576e227e";
screenInfo="1200:1600";
scopus.machineID="BA7B0A2DE68145227A15258B91065776.FZg2ODcJC9ArCe8WOZPvA";
s_vnum="1435701600695%26vn%3D4";
s_vi="[CS]v1|2AC743430530A9CC-4000030400122E0C[CE]";
s_sq="%5B%5BB%5D%5D";
s_ppv="-";
s_nr="1435418814232-Repeat";
s_lv_s="Less%20than%201%20day";
s_lv="1435418814236";
s_invisit="true";
s_fid="626A1991A0909E8C-243E12C87B514B09";
s_cc="true";
javaScript="true";
homeAcc_cookie="0045...003D";
gpv_p19="Search%20-%20advanced";
__cfduid="d051c8615981e5195822cfa64e0a9b5d11435403904";
__cfduid="d19c5d5d8cbb070f3d2925bb5699863f71435420566";
SCSessionID="D7BE9A26CF08EFC5C8C74ED2B74C3B9F.mw4ft95QGjz1tIFG9A1uw";
CARS_COOKIE="0062...0061";
AE_SESSION_COOKIE="1435420566767";

Cookie: original cookies observe by fiddler
xmlHttpRequest=true;
utt=b7ac8bc0fcbc41a109ec14911f12df576e227e;
screenInfo=1200:1600;
scopus.machineID=DDC0CE447848D6DCF672F306717D1080.mw4ft95QGjz1tIFG9A1uw;
s_vnum=1435701600695%26vn%3D4;
s_vi=[CS]v1|2AC743430530A9CC-4000030400122E0C[CE];
s_sq=%5B%5BB%5D%5D
s_ppv=-;
s_nr=1435418824590-Repeat;
s_lv_s=Less%20than%201%20day;
s_lv=1435418824591;
s_invisit=true;
s_fid=626A1991A0909E8C-243E12C87B514B09;
s_cc=true;
javaScript=true;
homeAcc_cookie=0045...003D;
gpv_p19=Document%20results%20list;
__cfduid=d051c8615981e5195822cfa64e0a9b5d11435403904;
SCSessionID=1492F64366A3F0549F28E94B4A09D043.fM4vPBipdL1BpirDq5Cw;
CARS_COOKIE=0075...003D;
AE_SESSION_COOKIE=1435410821435;
acw=af257d028b43e41898119f4-876472f4a5ded1cd%7C%24%7Co8ylJ9HfDIJUkW5A%2BDxL%2BxI...HfA8%2BsypOAq;
gpv_e23=Implicit;
#33812
Posted: 06/27/2015 12:32:01
by Eugene Mayevski (EldoS Corp.)

When you add a cookie, set its Format property to "cfRFC6265". This should solve the problem.

The cause of the problem is that there existed 4 editions of the standard for cookies, and those standards are incompatible / conflicting with each other. RFC 6265 (the latest one) reverts most features and ideas of the previous standard (RFC 2965).


Sincerely yours
Eugene Mayevski
#33813
Posted: 06/27/2015 12:35:35
by Walter Schrabmair (Priority Standard support level)
Joined: 05/03/2013
Posts: 150

where can I set the Format property?
#33814
Posted: 06/27/2015 12:47:49
by Walter Schrabmair (Priority Standard support level)
Joined: 05/03/2013
Posts: 150

I have done this in this way. No TECookie class used.
Code
begin
   mySearch:=TMemorystream.create;
   MyCookie:=TElCookie.create;
   MyCookie.AssembleClientCookie(cfRFC6265);

   DPMAStage:=1;
   ElHttpsclient1.Get('http://www.scopus.com/');

   DPMAStage:=11;
   cookies.clear;
   cookies.Add('utt=b7ac8bc0fcbc41a109ec14911f12df576e227e'); // ;
   //cookies.Add('__cfduid=d051c8615981e5195822cfa64e0a9b5d11435403904');
   //cookies.Add('SCSessionID=1492F64366A3F0549F28E94B4A09D043.fM4vPBipdL1BpirDq5Cw'); // ;
   //cookies.Add('AE_SESSION_COOKIE=1435410821435'); // ;
   //cookies.Add('CARS_COOKIE=0075...003D'); // ;
   //cookies.Add('homeAcc_cookie=0045...003D'); // ;
   //cookies.Add('acw=af257d028b43e41898119f4-876472f4a5ded1cd%7C%24%7Co8ylJ9HfDIJUkW5A%2BDxL%2BxI...HfA8%2BsypOAq'); // ;
   //cookies.Add('scopus.machineID=DDC0CE447848D6DCF672F306717D1080.mw4ft95QGjz1tIFG9A1uw'); // ;
   cookies.Add('javaScript=true'); // ;
   cookies.Add('xmlHttpRequest=true'); // ;
   cookies.Add('screenInfo=1200:1600'); // ;
   cookies.Add('s_cc=true'); // ;
   cookies.Add('s_vnum=1435701600695%26vn%3D4'); // ;
   cookies.Add('s_ppv=-'); // ;
   cookies.Add('s_fid=626A1991A0909E8C-243E12C87B514B09'); // ;
   cookies.Add('s_nr=1435418814232-Repeat'); // ;
   cookies.Add('s_invisit=true'); // ;
   cookies.Add('s_lv=1435418814236'); // ;
   cookies.Add('s_lv_s=Less%20than%201%20day'); // ;
   cookies.Add('gpv_p19=Search%20-%20advanced'); // ;
   cookies.Add('s_sq=%5B%5BB%5D%5D'); // ;
   cookies.Add('s_vi=[CS]v1|2AC743430530A9CC-4000030400122E0C[CE]'); // E]
   cookies.Add('acw=af257d028b43e41898119f4-876472f4a5ded1cd%7C%24%7Co8ylJ9HfDIJUkW5A%2BDxL%2BxI...HfA8%2BsypOAq');
   cookies.Add('gp_e23=Implicit');
   ElCookieManager1.SetCookiesForURL('http://www.scopus.com', cookies,NOw, 0);
  


And the result is teh same. WIth "
#33815
Posted: 06/27/2015 14:09:20
by Eugene Mayevski (EldoS Corp.)

In this case you also need to specify the format of the cookies in the last parameter of SetCookiesForURL . Please set this parameter to cfRFC6265 .


Sincerely yours
Eugene Mayevski
#33816
Posted: 06/28/2015 01:40:15
by Walter Schrabmair (Priority Standard support level)
Joined: 05/03/2013
Posts: 150

ok, thanks.
But how can I define the Format cfRFC6265 for the coookies that are handled by the cookiemanager automatically? I mean I have cookies that are sent by the server and returned from the client to the server automatically by the manager. THese cookies are still with the ".
Thanks
#33817
Posted: 06/28/2015 02:52:01
by Eugene Mayevski (EldoS Corp.)

Right now the default value of Format property is cfUndefined. You would need to walk through the domains and cookies in the cookie manager and set Format property for them.

In SecureBlackbox 13 we've changed the default format of the cookies received from the server to cfRFC6265, so this problem will go away.


Sincerely yours
Eugene Mayevski
#33818
Posted: 06/28/2015 05:21:13
by Walter Schrabmair (Priority Standard support level)
Joined: 05/03/2013
Posts: 150

Thanks, that is fine, that this is done in release SBB 13.
Also by EldoS: Callback File System
Create virtual file systems and disks, expose and manage remote data as if they were files on the local disk.

Reply

Statistics

Topic viewed 1141 times

Number of guests: 1, registered members: 0, in total hidden: 0




|

Back to top

As of July 15, 2016 EldoS Corporation will operate as a division of /n software inc. For more information, please read the announcement.

Got it!