Recent

Author Topic: How can I learn the Set-Cookie value of the web page  (Read 6383 times)

loaded

  • Hero Member
  • *****
  • Posts: 825
How can I learn the Set-Cookie value of the web page
« on: December 14, 2016, 07:36:22 am »
Hi all
First of all, I did a lot of research on the subject.
But I did not find a remedy
My problem is learning Set-Cookie value
Code: Pascal  [Select][+][-]
  1. var
  2.   HTTP: THTTPSend;   //for install synapse component http://www.ararat.cz/synapse/doku.php/download
  3. begin
  4.     HTTP := THTTPSend.Create;
  5.     try
  6.       HTTP.HTTPMethod('GET', 'http://forum.lazarus.freepascal.org');
  7.       showmessage(HTTP.Cookies.Text);  //This code is working
  8.     finally
  9.       HTTP.Free;
  10.     end;
  11.  
  12.     HTTP := THTTPSend.Create;
  13.     try
  14.       HTTP.HTTPMethod('GET', 'https://www.microsoft.com');
  15.       showmessage(HTTP.Cookies.Text); //This code is not working
  16.     finally
  17.       HTTP.Free;
  18.     end;
  19. end;  
  20.  

How can I learn the cookie value given by the https://www.microsoft.com page. Thank you for helping already.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

Fungus

  • Sr. Member
  • ****
  • Posts: 353
Re: How can I learn the Set-Cookie value of the web page
« Reply #1 on: December 14, 2016, 12:35:51 pm »
Running the command "curl --head https://www.microsoft.com/" returns:

Code: [Select]
HTTP/1.1 200 OK
Server: Apache
ETag: "6082151bd56ea922e1357f5896a90d0a:1425454794"
Last-Modified: Wed, 04 Mar 2015 07:39:54 GMT
Accept-Ranges: bytes
Content-Length: 1020
Content-Type: text/html
Date: Wed, 14 Dec 2016 11:34:30 GMT
Connection: keep-alive

Since there are no cookies send by the server, you cannot retreive them.

Thaddy

  • Hero Member
  • *****
  • Posts: 14389
  • Sensorship about opinions does not belong here.
Re: How can I learn the Set-Cookie value of the web page
« Reply #2 on: December 14, 2016, 12:56:52 pm »
There's an etag, though?
And a keep alive.
MS has best practice for connections( i.e: no infringement on user storage space with cookies on most MS websites), but these two are enough to identify a connection.
Etags are just as bad as cookies.

If it is just to analyze MS traffic? Don't.


« Last Edit: December 14, 2016, 12:58:27 pm by Thaddy »
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

loaded

  • Hero Member
  • *****
  • Posts: 825
Re: How can I learn the Set-Cookie value of the web page
« Reply #3 on: December 14, 2016, 12:58:18 pm »
Thank you for your reply Fungus.

Running the command "curl --head https://www.microsoft.com/" returns:

Code: [Select]
Server: Apache

Microsoft Apache  :o   I mean the curl works wrong.

Cookie value that appears on internet explorer
« Last Edit: December 14, 2016, 01:02:27 pm by loaded »
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

Fungus

  • Sr. Member
  • ****
  • Posts: 353
Re: How can I learn the Set-Cookie value of the web page
« Reply #4 on: December 14, 2016, 01:03:45 pm »
You are referencing different URI's and each may have a different response. Curl'ing https://www.microsoft.com/tr-tr/ yields:

Code: [Select]
HTTP/1.1 200 OK
Cache-Control: no-cache, no-store
Pragma: no-cache
Content-Length: 71330
Content-Type: text/html
Expires: -1
Server: Microsoft-IIS/8.0
CorrelationVector: XX
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
Access-Control-Allow-Headers: Origin, X-Requested-With, Content-Type, Accept
Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
Access-Control-Allow-Credentials: true
P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI"
X-Frame-Options: SAMEORIGIN
Date: Wed, 14 Dec 2016 12:00:30 GMT
Connection: keep-alive
Set-Cookie: MS-CV=XX; domain=.microsoft.com; expires=Thu, 15-Dec-2016 12:00:29 GMT; path=/
Set-Cookie: MS-CV=XX; domain=.microsoft.com; expires=Thu, 15-Dec-2016 12:00:30 GMT; path=/
Strict-Transport-Security: max-age=31536000
Set-Cookie: akacd_OneRF=XX~rv=XX~id=XX; path=/; Expires=Tue, 14 Mar 2017 12:00:30 GMT
X-CCC: DK
X-CID: 2

Actual values may have been replaced with XX :)

Thaddy

  • Hero Member
  • *****
  • Posts: 14389
  • Sensorship about opinions does not belong here.
Re: How can I learn the Set-Cookie value of the web page
« Reply #5 on: December 14, 2016, 01:06:08 pm »
That's different.
Bing.com is MS owned but blocked if you block it ;) It is a redirect. You need to handle that separately. That is not MS.
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.

loaded

  • Hero Member
  • *****
  • Posts: 825
Re: How can I learn the Set-Cookie value of the web page
« Reply #6 on: December 14, 2016, 01:14:49 pm »
Thank you for your answers Fungus and Thaddy
Congratulations, Yes correct detection.
When I wrote www.microsoft.com it becomes https://www.microsoft.com/tr-tr/ in the browser.
OK, how can we get the cookie value coming from the site with any https extensions.
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

Fungus

  • Sr. Member
  • ****
  • Posts: 353
Re: How can I learn the Set-Cookie value of the web page
« Reply #7 on: December 14, 2016, 01:51:03 pm »
You need to enable SSL on the socket. I'm not expert in Synapse, but this may work:

Code: Pascal  [Select][+][-]
  1. HTTP.Sock.CreateWithSSL(TSSLOpenSSL);
  2. HTTP.Sock.SSLDoConnect;

http://stackoverflow.com/questions/11377320/synapse-delphi-https-ssl-get-request

loaded

  • Hero Member
  • *****
  • Posts: 825
Re: How can I learn the Set-Cookie value of the web page
« Reply #8 on: December 15, 2016, 06:45:45 am »
Thank you so much Fungus
I tried the codes,Unfortunately did not work  :-\
Check out  loaded on Strava
https://www.strava.com/athletes/109391137

 

TinyPortal © 2005-2018