I'm doing a simple chat script and I have the killSession function
which kills the current session and deletes the user from the DB. The
problem is that after the name is set and verified the chat form
doesn't load, it just kills the session and goes back to the loginForm
(). Here's the script:

<?php
if(!isset($_SESSION['name'])){
        loginForm(); // set a name for chat
} else {
?>
        // chat form

        $(window).unload( function () {
                <?php  killSession(); ?>
        });

Is there a way to trigger killSession() only after I refresh or close
the page?

Reply via email to