php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #15310 when use object method call session register doesn't work
Submitted: 2002-01-31 04:50 UTC Modified: 2002-07-02 01:00 UTC
Votes:8
Avg. Score:4.2 ± 1.0
Reproduced:4 of 5 (80.0%)
Same Version:1 (25.0%)
Same OS:3 (75.0%)
From: nail at bowling dot nsk dot su Assigned:
Status: No Feedback Package: Session related
PHP Version: 4.1.1 OS: linux
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 this is not your bug, you can add a comment by following this link.
If this is your bug, but you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: nail at bowling dot nsk dot su
New email:
PHP Version: OS:

 

 [2002-01-31 04:50 UTC] nail at bowling dot nsk dot su
Following code the shows strange bag.
When function t() called as object method, variable 'time' is not kept in session.
Register_globals is On.

<?php
session_start();
class Test {
    var $mT = array();
    // this function does not deal with session
    function t()
    {
        reset($GLOBALS);
        while (list($k,$v)=each($GLOBALS))
            $GLOB[$k]=$v;
        $this->mT['TEST'] = $GLOB;
    }
}
$test = new Test;
$test->t(); // comment this line and script will work right
?>
<pre>
<?php
print_r($_SESSION);
$_SESSION['time'] = time();
session_register('time');
echo "\n-------new _SESSION:-----------\n\n";
print_r($_SESSION); echo "\n";
?>
</pre>

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-01-31 05:31 UTC] yohgaki@php.net
As I changed session manual recently,
NEVER use $_SESSION(or $HTTP_SESSION_VARS) AND session_register/is_registered/unregister() functions.
(It's not only for 4.1.x but also for 4.0.x)

I warned it already. 

tracked vars and globals are handled inconsistent manner in session module. 
I really would like to get rid of global var support from session module for PHP5....
 [2002-01-31 06:06 UTC] nail at bowling dot nsk dot su
I have removed session_register() call and began new session,  but it has not given result.
 [2002-02-01 02:22 UTC] yohgaki@php.net
What do you mean "it has not given result".

If you mean $time does not have value, it's normal.
if $_SESSION['time'] does not have value something wrong.
If you mean you don't see $test->$mT['TEST']['_SESSION_']['time'] does not have value, it's your bug.

Please try to be more specific.


 [2002-02-01 02:49 UTC] nail at bowling dot nsk dot su
I mean value of $_SESSION['time'] lost at refresh.
When I comment line $test->t() script works correctly:

Array
(
    [time] => 1012549372
)

------------------new _SESSION:--------------------------

Array
(
    [time] => 1012549373
)

When I remove comment the output is like this (don't forget begin new session):

Array
(
)

------------------new _SESSION:--------------------------

Array
(
    [time] => 1012549537
)
 [2002-04-14 00:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2002-04-14 08:12 UTC] sniper@php.net
reopen..the feedback _was_ given.

 [2002-06-01 11:43 UTC] mfischer@php.net
Somehow the responses got out of sync.

Please a) try a newer version of PHP (we're at 4.2.1) and b) try a new, self-contained example with the suggestions given.
 [2002-07-02 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 [2002-07-25 23:31 UTC] bemore15 at yahoo dot com
I have this bug on Windows 2000 PHP 4.2.1.

$member = $auth->create_member_object($login, $password);
$_SESSION["member"] = $member;
$member->init();

...
$member->init() redirects the session to another page
That page starts:

<?

require ("includes/common.php");
$member = $_SESSION["member"];

...
I have this bug regardless of the order of the following lines:

require ("includes/common.php");
$member = $_SESSION["member"];
session_start()

...
The output is:
Notice: Undefined index: member in [file].php on line 4
 [2007-10-12 19:39 UTC] dharmesh_radadiyaa at hotmail dot com
what is meaning of session?
what is meaning of register?
what is meaning of cookies?
 [2007-10-12 19:41 UTC] dharmesh_radadiyaa at hotmail dot com
what is meaning of session?
what is meaning of register?
what is meaning of cookies?
 [2008-04-09 12:33 UTC] uriiniix at gmail dot com
The problem still here. I wonder why you haven't fixed yet! 6 years passed!!!! 

The problem is next: 
I have 3 files:

------ session.php ----------

class Session {
 
  function Session()
  {
      session_start();
  }

  function RegObject($object)
  {
     session_register('object_instance');
     $_SESSION['object_instance'] = $objects;
  }

  function GetObject()
  {
     return $_SESSION['object_instance'];
  }
}


-------- addObject.php --------------

  $session = new Session();
  $obj = new ObjectClass();


  $session->RegObject($obj);



--------- getObject.php -------------

  $session = new Session();
  $obj = $session->GetObject();

  print ">>>".$obj; // Here as output should be error that ObjectClass could not be converted to string, but only ">>>" printed


The root of the problem seams in accessing $_SESSION.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 18 11:01:28 2024 UTC