Destroying sessions in PHP

Posted on

Question :

I was researching about logout functions in php and I saw examples like:

if(isset($_SESSION)) { 
     unset($_SESSION['minhaSessao']); //repetir para cada sessao
     session_unregister(); 
     session_destroy(); 
}

I wanted to know if there is any way to clear all the active sessions of my application without having to set one by one repeatedly.

    

Answer :

This code is redundant, only session_destroy(); alone solves the case. You do not need if , nor other commands.

link

    

create a file with only session_destroy(); and use logoff, it is enough to break all php sessions

    

Leave a Reply

Your email address will not be published. Required fields are marked *