Note that there are some explanatory texts on larger screens.

plurals
  1. POSet remote cookie with script-tag?
    primarykey
    data
    text
    <p>Scenario:</p> <ol> <li><p>User visits <code>http://some-site.test/form.html</code>. The page contains a form:</p> <pre><code>&lt;form action="http://example.com/search" method="post"&gt; ... </code></pre></li> <li><p>User fills out and submits the form.</p></li> <li><p>The action <code>http://example.com/search</code> performs a search and shows the result, but <em>only</em> if a cookie has been sent together with the form data:</p> <pre><code>ASP.NET_SessionId=... </code></pre> <p>In other words: A session needs to be already established with <code>example.com</code>, or otherwise search will not work. I have no idea why that is the case, and I currently have to way to contact the person in charge of search.</p></li> </ol> <p>As a workaround, I added a script tag in <code>form.html</code>:</p> <pre><code>&lt;script src="http://example.com"&gt;&lt;/script&gt; </code></pre> <p>Amazingly this works: The cookie <code>ASP.NET_SessionId</code> is set. However, it is an ugly solution because the script tag causes a full HTML page to be loaded, and consequences are uncertain. In Chrome the consequence is an error message visible in the console:</p> <pre><code> Uncaught SyntaxError: Unexpected token &lt; </code></pre> <p>My question:</p> <blockquote> <p>Is there a better solution to set the cookie before submitting the form?</p> </blockquote> <p>What else I have considering so far:</p> <ul> <li><p>A hidden <code>iframe</code> with <code>src="http://example.com"</code>. Disadvantages:</p> <ul> <li><p>It would be necessary to detect when the page behind <code>http://example.com</code> is loaded, and only then the form should be made visible. However, as far as I can tell, <code>iframe</code> doesn't officially (W3C) support the <code>onload</code> attribute. While that attribute nevertheless works in many browsers, I have read that it doesn't work in IE &lt;= 8. The same is true for the associated load-event.</p></li> <li><p>More than just the HTML would be loaded, i.e. CSS, images, etc. This is a waste of bandwidth, and in fact already loading the HTML is unnecessary. Only the setting of the cookie is needed.</p></li> </ul></li> <li><p>A hidden <code>img</code> with <code>src="http://example.com"</code>. Disadvantage: <code>img</code> doesn't fire the load-event for HTML content, at least in Chrome.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload