php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #45719 session_destroy behaviour documentation incomplete (or unclear)
Submitted: 2008-08-05 10:18 UTC Modified: 2008-11-05 10:26 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:0 of 0 (0.0%)
From: markvanstraten at gmail dot com Assigned:
Status: Closed Package: Documentation problem
PHP Version: Irrelevant OS: Windows XP
Private report: No CVE-ID: None
 [2008-08-05 10:18 UTC] markvanstraten at gmail dot com
Description:
------------
session_destroy() does not only unset the values in the session but disables the session completely, untill another call to session_start() is issued. 

This is not documented behaviour and should be. It will save people som e time. It is mentioned in the user comments but way down the line, not the first place to search for the description of behaviour.



Reproduce code:
---------------
<?php
session_start();
echo 'current id is ',session_id(),PHP_EOL;
//set value in session
$_SESSION['foo'] = 'bar';
echo 'value set in session, current content:',PHP_EOL;
print_r($_SESSION);

//destroy session content
session_destroy();
echo 'session destroyed, current content: ',PHP_EOL;
print_r($_SESSION);
echo 'current id is ',session_id(),PHP_EOL;

//regenerate ID?
session_regenerate_id();
echo 'regenerated id',PHP_EOL;
echo 'current id is ',session_id(),PHP_EOL;

//start new session?
session_start();
echo 'started new session',PHP_EOL;
echo 'current id is ',session_id(),PHP_EOL;

//regenerate ID?
session_regenerate_id();
echo 'regenerated id',PHP_EOL;
echo 'current id is ',session_id(),PHP_EOL;

?>

Expected result:
----------------
I would have expected that session_destroy() would only affect the current values of the session. 

Possibly, i had expected that session_regenerate_id() would (under the surface) call session_start() for me if not already available.

Actual result:
--------------
session_destroy() destroy's the session with the values and the session_id

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-08-05 10:21 UTC] markvanstraten at gmail dot com
changed title to be more descriptive
 [2008-11-05 10:26 UTC] vrana@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.

"To use the session variables again, session_start() has to be called."
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Fri Oct 09 00:00:01 2026 UTC