php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #10845 session_destroy() bugs
Submitted: 2001-05-14 05:42 UTC Modified: 2001-06-10 21:26 UTC
From: david at sprat dot co dot nz Assigned:
Status: Closed Package: Session related
PHP Version: 4.0.5 OS: Redhat Linux 7
Private report: No CVE-ID: None
 [2001-05-14 05:42 UTC] david at sprat dot co dot nz
I have had a lot of problems with trying to destroy a session with session_destroy() as have many others I see, and none of the solutions brough up seem to work reliably.

What I found is that if I made any session-related functions (such as session_register etc) AFTER session_destroy(); in code, PHP returned an error.

This is regardless of whether session_destroy() was in another branch of a conditional statement:

e.g.

1 if(condition){
2   session_destroy();
3 {
4 else{
5   session_register("variable");
6 }

would return the error like "Warning: Cannot send session cache limiter - headers already sent (output started at /test.php:5) in /test.php on line 5)"

So even though session_register() would not be called if session_destroy was called and vice versa because of the branch in code, PHP still didn't like this.

The way to get around this is:

if(!condition){
    session_register("variable");
{
else{
    session_destroy();
}

Anyway, hopefully this will help you find the source of this frustrating problem so it can be fixed.

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-05-14 06:25 UTC] derick@php.net
Hello,

the "headers already sent" message suggests that you have some whitespace in your code, or you did output some other data (like HTML, or printed text with echo() or print).
Can you check this please?

Derick
 [2001-06-10 21:26 UTC] jmoore@php.net
No feedback. Closing.

- James
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Sep 07 20:01:28 2024 UTC