PHP execute code on page close
<p>I am trying to find a method to execute some PHP code once a user closes the page. In my application, once the user closes or navigates away from the page the server will state the user as 'Offline' in the database. This requires the code to know when the user has navigated away from the page. My application also has an endless load (i.e. it will sleep until the user closes the page).</p>

<p><strong>Edit:</strong></p>

<p>Thanks for the answers. I decided to go with Pekka's session method, as this seemed the most logical for my application.</p>

<p>Cheers</p>
