php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #14364 Unable to clear out an individual variable in a session
Submitted: 2001-12-06 14:40 UTC Modified: 2001-12-07 20:34 UTC
From: info at somnioworld dot com Assigned:
Status: Closed Package: Session related
PHP Version: 4.1.0 OS: FreeBSD 4.2
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: info at somnioworld dot com
New email:
PHP Version: OS:

 

 [2001-12-06 14:40 UTC] info at somnioworld dot com
There appears to be an issue with unsetting variables in a session. I have an object variable that is stored in the session and when I attempt to unset the value via unset(object) and session_unregister(object) and test if(isset(object)) to see if it is set in a seperate script the test passes.  In PHP 4.05 I did not encounter this problem.

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2001-12-06 14:44 UTC] jan@php.net
Can you provide the shortest sample script, that reproduce that bug?
 [2001-12-06 14:45 UTC] derick@php.net
Fixed in CVS. BTW, 4.1.0 does not exist yet, so how can you report a bug for it?
This fix will be in the 4.1.0 release.

Derick
 [2001-12-06 17:05 UTC] info at somnioworld dot com
Sample script:

// script to create session variable
session_start();
session_register("objectA");
$objectA = new classA();

// script to unset session variable
session_start();
session_unregister("objectA");
unset($objectA);

// script to test for session variable
session_start();
if(isset($objectA))
{
  echo "TEST PASSED";
}


Doing a session_destroy() then unset() of all the session variables seems to work, but in the above code I wish to just unset() a single variable in the session but keep the session and the remaining variables alive.
 [2001-12-06 17:12 UTC] derick@php.net
No worries! It's already fixed in CVS.
 [2001-12-06 22:08 UTC] info at somnioworld dot com
We downloaded and installed the CVS version today (version 4.2) and we are still having the same issue.
 [2001-12-07 01:28 UTC] derick@php.net
Are you sure you did that after the fix?

file /ext/session/php_session.h should include this (around line 168):

#define PS_DEL_VARL(name,namelen)                                          \
   zend_hash_del(&PS(vars), name, namelen+1);                   \
   if (PS(http_session_vars)) {                                            \
       zend_hash_del(Z_ARRVAL_P(PS(http_session_vars)), name, namelen+1);  \
   }


Does it do that, and did you rebuild from a fresh tree?

Derick
 [2001-12-07 11:45 UTC] info at somnioworld dot com
Those lines are not in my /ext/session/php_session.h

I installed the CVS version this afternoon.  I followed the instruction on php.net's site:

http://www.php.net/anoncvs.php

I did it from a new dir, so the tree is fresh.  I was also running php4.1 rc5 prior to the upgrade and now after the upgrade I am running php4.2 which is the cvs version I got today.  Where should I get the CVS version that has the fix?  Or can I just add the lines in that you posted to the source to get it to work correctly?  What do you recommend?
 [2001-12-07 12:46 UTC] derick@php.net
It is certainly in the php 4.2.0 cvs tree, as I just downloaded it here.
with the instructions on that site, you should have the correct version too (with the fix).
Can you please check again of lines 169-173 in php4/ext/session/php_session.h have these lines of codE:

#define PS_DEL_VARL(name,namelen)                                           \
    zend_hash_del(&PS(vars), name, namelen+1);                              \
    if (PS(http_session_vars)) {                                            \
        zend_hash_del(Z_ARRVAL_P(PS(http_session_vars)), name, namelen+1);  \
    }

regards,
Derick
 [2001-12-07 13:25 UTC] info at somnioworld dot com
I did check again and you are right, the lines of code you posted are in the version I installed.  However, I am still having the issues with the session.  I have tested it several times and when I try unsetting session variables and unregistering session variables it still doesn't work.  Let me know what I need to do to help get this resolved.  I truely appreciate the help
 [2001-12-07 13:34 UTC] mfischer@php.net
Feedback.

Please provide a short, reproduceable copy&paste sample.
 [2001-12-07 14:13 UTC] info at somnioworld dot com
Ok, it looks like I have everything resolved.  In the previous version of PHP (4.0.5) I was able to clear out a session variable by just using the unset() function.  Now with the new CVS it appears that I have to session_unregister() and unset() the session variable to clear it out.

Thank you for your support!
 [2001-12-07 20:34 UTC] sniper@php.net
This is fixed in latest CVS. I can't reproduce it whatever the 
register_globals is.

--Jani

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Wed May 07 19:01:32 2025 UTC