Load a page to get cookie and read source code at the same time
<p>I am searching 3 days for an answer and I cannot find one because I always find some obstacles. </p>

<p>I need to load a web page (the reason for this is to accept a cookie) and then at the same time read the source code of the new page without hitting it again. The reason for this is that the page is dynamic so the content will change.<br>
I have tried to do this using iFrame(<code>document.body.innerHTML</code>) but the fact that these pages run on different servers I hit cross-site scripting issues.<br>
I have also tried writing a php script using <code>get_contents</code> but this doesn't allow the cookie to be stored in my local.</p>

<p>This is driving me crazy.... Any suggestion will be helful! Need to use PHP or Javascript for this and any other suggestion will be useful as well.</p>
