Explain the PHP code segment given below.
if(isset($_SESSION["uname"])) {session_destroy();}
ISSET is the function to check the value of the variable has been set or not. If the variable value has not been set it will return FALSE otherwise if set, then it will return TRUE.
Here in our case of if(isset($_SESSION["uname"])) the isset function will check whether the running season's uname or username is set/assigned or not. If it has been set then it will return TRUE to the if function.The if condition also returns TRUE if the value of SESSION["uname"] has been set, and the block inside the if condition will get executed otherwise not.
If the if condition returns TRUE, then the function session_destroy() will get executed .and all the data associated with the current running session will get destroyed.
Comments
Leave a comment