Run PHP onClick - session_destroy

lbudbeardq

New Member
I am looking to destroy the session when a user clicks "Log Out", I am trying to do this by calling a function onClick using jQuery which will then call a .PHP file which contains, \[code\]session_destroy();\[/code\].index.php\[code\]<?php if(isset($_SESSION['username'])) { echo "<li><a href='http://stackoverflow.com/questions/15506476/#' id='logOut' onclick='logOut();'>Log Out</a></li>";}?>\[/code\]This makes the log out button visible only when a user is logged in and when onClick should call \[code\]logOut()\[/code\] which is contained in Nav.js.Nav.js\[code\]function logOut() { $.get("../Controller/logOut.php"); return false;}\[/code\]logOut.php\[code\]<?php session_destroy();?>\[/code\]When I click "Log Out" nothing seems to happen and I am not getting any errors in Chrome Dev console. What is the problem?
 
Back
Top