Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you really need to make sure that a link only creates an event once, then you need to implement a token system, where when a hyperlink (or a form post target) is generated, a use once token is generated and stored (in the session or wherever), and then is checked in the calling script.</p> <p>So your hyperlink may look like this:</p> <pre><code>&lt;a href='download.php?token={some-token}&amp;f={$item['name']}&amp;t={$type}' target='_blank'&gt;{$item['name']}&lt;/a&gt; </code></pre> <p>On the php side this is a really simplified idea of what you might do:</p> <pre><code>&lt;?php session_start(); if (!isset($_REQUEST['token']) die(); // or fail better if (!isset($_SESSION['oneTimeTokens'][$_REQUEST['token']) die(); // or fail better if ($_SESSION['oneTimeTokens'][$_REQUEST['token']=='used') die(); // or fail better $_SESSION['oneTimeTokens'][$_REQUEST['token']='used'; // we're good from this point </code></pre> <p>This would solve the effects of your problem, though not the double running itself. However since you want to make sure a link is firing an event only once NO MATTER WHAT, you probably implement this in some form or another as it's the only way to guarantee that any link generated has a one real use life that I can think of.</p> <p>When generating the link you would do something like this in your code:</p> <pre><code>&lt;?php $tokenID = {random id generation here}; $_SESSION['oneTimeTokens'][$tokenID] = 'not used'; </code></pre> <p>I'd also somewhere put a cleanup routine to remove all used tokens. Also, it's not a bad idea to expire tokens beyond a certain age, but I think this explains it.</p>
 

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