Clear php session

From snippet wiki
Jump to: navigation, 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');

Autoren der Seite / Contributors of the page

» Kai Kretschmann, (google+)