I know PHP is server side and JS is browser.
Is it possibe to put php code inside a javascript function.
ie
body <onUnload="finish();">
<script="javascript">
function finish() {
<?php
UNSET($_SESSION['foo'])
?>
</script>
as you can see from the php i am altering a session variable(the session was started at the head of the page, obviously)
So 2 questions really if php can be executed in javascript functions can the $_SESSION vars be altered or would this require another session_start() because headers have been sent??
when i have tested this, the PHP code seems to always be execued when the page is loaded?? so my SESSION var is cleared? and it actually damages other vars in the $_SESSION??
if it does work i could use this further to know when someone has logged off perhaps and delete then from files?