title: How to pass a query parameter along with a redirect in JavaScript
body: <p>Right now redirection is made simply by saying</p>
  
  <pre><code>window.location = "/relative_path/";
  </code></pre>
  
  <p>What I want to do is to add a query parameter along with this redirection, so the destination page can look at that, and after some action was taken it could redirect further to that page.</p>
  
  <p>Example for that use is a login system. When the user's token expires, he is redirected to the login page. At the time of the redirection I want to pass along the exact URL (including query parameters in the URL) to the login page, so after a successful login the user could be redirected back exactly to the point where he/she was.</p>
  
  <p>I tried to pass the path as a URL parameter, but that doesn't work because of escaping issues: the redirect url uses the same characters (?, =, ...), which confuses the system, and the parameters get truncated.</p>
  
  <p>So something like that, but this obviously doesn't work:</p>
  
  <pre><code>window.location = "/login?redirect=/original_location?p1=vl1&amp;p2=v2
  </code></pre>
  
  <p>Any suggestion is appreciated.</p>