Got it from php.net, but I am not sure is this how everybody destroy all sessions?
// Unset all Sessions $_SESSION = array(); if (isset($_COOKIE[session_nam
If you want to avoid the warning:
Warning: session_destroy(): Trying to destroy uninitialized session in ... on line 18
Don't forget to add session_start(); to the beginning of your code. Other than that the code you provided works as intended.
session_start();