You can use a trigger of <?php echo(isset($_GET["logout"])?"1":""); ?>
That would allow you to logout with <a> tag by just using <a href="page.php?logout">log out</a>
It might be best if you can send me FTP access and a url to reproduce your issues. Then I can take a look at what you have done and test it live and make any necessary updates for you to save some time back and forth.