Clear php session

From snippet wiki
Jump to navigation Jump to search

This backend php code for a logout function clears away anything.

session_start();
$_SESSION = array();

$params = session_get_cookie_params();
setcookie(
	session_name(), '', time() - 86400,
	$params["path"], $params["domain"], $params["secure"]
);

session_destroy();

header('Location: ../login.php');