php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #25706 session_start() destroys my object
Submitted: 2003-09-30 14:46 UTC Modified: 2003-09-30 14:54 UTC
From: str at strgt dot cjb dot net Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.1.2 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 you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: str at strgt dot cjb dot net
New email:
PHP Version: OS:

 

 [2003-09-30 14:46 UTC] str at strgt dot cjb dot net
Description:
------------
This is a weird bug, because I do only get it in some browsers.  
It works fine in IExplorer, links, but not in Konqueror. All  
browsers are "cookies enable". I have a class, with some  
vars. When I use session_start  in a class->function, i cannot  
access $this nor $this->vars  
 
I read some similar bugs are in php4.0 and solved in 4.1.0 and 
I have 4.1.2 

Reproduce code:
---------------
class PayUser {
  var $pay_user, $passwd, $ses_id, $db, $new;
  function PayUser($id) {
    include_once("base.php");  // this is where i create $db
    $this->db = $db;
    $select = $this->db->exec("SELECT * from pay_users where p_user='$id'");   // this means $this->db exists and it works 
  /// code omited..
  }
  function login($pass) {
	// print_r($this)  //  before the session_start()  prints me the object
    session_start();
     print_r($this)  /// after session_start() $this is not asigned
      $sid = session_id();
      $sql = "UPDATE pay_users SET ses_id='$sid' where p_user='".$this->pay_user."'";
      $this->db->exec($sql);  // Fatal error: Call to a member function on a non-object in this line...  because $this does not exist 
 // more code omited


Expected result:
----------------
in the print($this) i should expect to print  
payuser Object ( 
    [db] => database Object ( 
            [con] => adodb_postgres7 Object ( 
                    [databaseType] => postgres7 
                    [hasLimit] => 1 
                    [ansiOuter] => 1 
                    [dataProvider] => postgres... 
 
and the $this->db->exec($sql);  should be executed, not to 
give the Fatal error: Call to a member function on a non-object 
in this line 
 
 

Actual result:
--------------
the error... and the $this is lost... 

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2003-09-30 14:52 UTC] sniper@php.net
1. Too old PHP version (we're at 4.3.3 and about to release 4.3.4 already)
2. Most likely bug in the browser.

 [2003-09-30 14:54 UTC] sniper@php.net
Also your script is flawed, ask support questions elsewhere.

 
PHP Copyright © 2001-2025 The PHP Group
All rights reserved.
Last updated: Sun Jul 06 09:01:32 2025 UTC