Destroy a PHP session on clicking a link
destroy, onclick, php, session, session-cookies
Solution
No it is not a valid code. It will destroy the session at the time of loading the php page.
For destroying session on click you should write
<a href="logout.php" >Logout</a>
in logout.php
session_destroy();
Problem
Is this code valid? ``` <a href="#" onclick="<?php session_destroy();?>">Logout</a> ```