1

The target of my form submit is an iframe. After, the response is loaded into my iframe, i want to read the cookies especially the jsessionid cookie of external link loaded into my iframe.

Please help me to resolve this issue.

imen laalai
  • 33
  • 1
  • 6
  • If the httpOnly flag is set, I think it is not possible to read the cookies. You can take a look at https://www.owasp.org/index.php/HttpOnly – HieuHT Jan 06 '16 at 15:48

2 Answers2

0

It is impossible because of the "same origin policy". You have to manually send a message (postMessage). See an example here: Accessing cookies of an iFrame in parent window

Community
  • 1
  • 1
0

I think that it can help you

    $ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://www.google.com");
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows NT 6.1; rv:11.0) Gecko/20100101 Firefox/11.0');
curl_setopt($ch, CURLOPT_HEADER ,1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER ,1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION ,1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
$content = curl_exec($ch);

// get cookies
$cookies = array();
preg_match_all('/Set-Cookie:(?<cookie>\s{0,}.*)$/im', $content, $cookies);

print_r($cookies['cookie']);
DXNNX
  • 11
  • 1
  • So, there is another way to display the response of the remote server without using iframe and read the cookies ? if yes, how can i do this? the following is my form submit form ID="the-form" action="mydomain.com/j_spring_security_check" method="post" target="my_iframe"> – imen laalai Jan 06 '16 at 16:04