Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / PHP

session_destroy()

Destroy the stored data associated with the active session and report success.

Version: PHP 8.4; repository runtime, production runtime not attested

Syntax

session_destroy(): bool

Destroy the stored data associated with the active session and report success. The current $_SESSION array and the browser’s session cookie are not cleared by this call. A full logout must also clear the application’s local session data and expire its cookie if used.

Signature

session_destroy(): bool

Example output

[true,"draft",true]

Examples

<?php
session_save_path(sys_get_temp_dir()); session_start(); $_SESSION["label"]="draft";
$ok=session_destroy(); echo json_encode([$ok,$_SESSION["label"],session_status()===PHP_SESSION_NONE]);

Result

[true,"draft",true]

Sources