Query string: Difference between revisions

Content deleted Content added
image + rfc link
query strings for tracking
Line 46:
<input type=submit>
 
and the user inserts the strings &ldquo;this is a fileldfield&rdquo; and &ldquo;was it clear (already)?&rdquo; in the two [[textfield]]s and presses the submit button, the program <code>test.cgi</code> will receive the following query string:
 
firstname=this+is+a+fileldfield&secondname=was+it+clear+%28already%29%3F
 
In [[UNIX]]-based [[web server]]s, the program receives the query string as an [[environment variable]] named <code>QUERY_STRING</code>
 
== See also Tracking==
 
A program receiving a query string can ignore part or all of it. If the requested URL corresponds to a file and not to a program, the whole query string is ignored. However, regardless of whether the query string is used or not, the whole URL including it is stored in the server [[log file]]s.
 
These facts allow query strings to be used to track users in a manner similar to that provided by [[HTTP cookie]]s. For this to work, every time the user download a page, a unique identifier is chosen and added as a query string to the URLs of all links the page contains. As soon as the user follows one of these links, the corresponding URL is requested to the server. This way, the download of this page is linked with the previous one.
 
For example, when a web page containing the following is requested:
 
<a href="frank.html">see my page!</a>
<a href="ciccio.html">mine is better</a>
 
an unique string, such as <code>sdfsd23423</code> is chosen, and the page is modified as follows:
 
<a href="frank.html?sdfsd23423">see my page!</a>
<a href="ciccio.html?sdfsd23423">mine is better</a>
 
The addition of the query string do not change the way the page is shown to the user. When the user follows, for example, the first link, the browser requests the page <code>frank.html?sdfsd23423</code> to the server, which ignores what follows <code>?</code> and sends the page <code>frank.html</code> as expected, adding the query string to its links as well.
 
This way, any subsequent page request from this user will carry the same query string <code>sdfsd23423</code>, making it possible to establish that all these pages have been viewed by the same user. Query strings are often used in association with [[web beacon]]s.
 
The main differences between query strings used for tracking and HTTP cookies are that:
 
# query strings form part of the URL, and are therefore included if the user saves or sends the URL to another user; cookies can be maintained across browsing sessions, but are not saved or sent with the URL
# if the user arrives to the same web server by two (or more) independent paths, it will be assigned two different query strings, while the stored cookies are the same
 
==See also==
 
* [[HyperText Transfer Protocol]]
* [[Common Gateway Interface]]
* [[HTTP cookie]]
* [[Web beacon]]
 
[[Category: Internet]]