you cannot use like this the correct way is
<script type="text/javascript">function Test() {
var _endSession = confirm("End current editing session ?");
if(_endSession == true)
{
unset($_SESSION['."'UsernameChosen'".');
?>
<script>
alert("Session terminated.");
}
else
{
alert("Session active.");
}
}</script>
</script>