php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1817 crashes when trying to reference a class object saved via session_register
Submitted: 1999-07-21 21:41 UTC Modified: 1999-09-15 07:14 UTC
From: john at trytel dot com Assigned:
Status: Closed Package: Reproducible Crash
PHP Version: 4.0 Beta 1 OS: Linux 2.3.5
Private report: No CVE-ID: None
 [1999-07-21 21:41 UTC] john at trytel dot com
Here is the error in /www/logs/error_log:
[Wed Jul 21 21:27:03 1999] [notice] Apache/1.3.6 (Unix) PHP/4.0B1 AuthMySQL/2.20 configured -- resuming normal operations
[Wed Jul 21 21:27:05 1999] [notice] child pid 349 exit signal Segmentation fault (11)


Here is my test file:
<? 
	require "php4lib.php3";

	if ( !isset($cart) ) {
		$cart = new Cart;
		$cart->debug = 1;
		$cart->init();
		$cart->add_item("1011", "AMD K6-3 450mhz", "250.00");
		$cart->save();
	} else {
		echo "'".$cart->items[idx]."'";	
	}
?>

This is php4lib.php3:
<?
class Cart {
	var $items;
	var $debug;

	function init() {
		session_start();
		if ($this->debug) echo "CART: Session started, ID is '".session_id()."'\n";
	}

	function save() {
		session_register("cart");
		if ($this->debug) echo "CART: Saved.\n";
	}

	function clear() {
		session_unregister("items");
		session_destroy();
		if ($this->debug) echo "CART: Items cleared, session destroyed.\n";
	}

	function add_item($idx, $desc, $price=0.00, $quantity=1, $long_desc="") {
		$this->items[idx] = $idx;
		$this->items[desc] = $desc;
		$this->items[price] = $price;
		$this->items[quantity] = $quantity;
		$this->items[long_desc] = $long_desc;
		if ($this->debug) echo "CART: Item added, '$idx, $desc, $price, $quantity, $long_desc.\n";
	}

	function remove_item($idx) {
		if ($this->debug) echo "CART: Item $idx removed.\n";
	}

	function inc_quantity($idx, $amount) {
		if ($this->debug) echo "CART: Item $idx quantity increased by $amount.\n";
	}

	function dec_quantity($idx, $amount) {
		if ($this->debug) echo "CART: Item $idx quantity decreases by $amount.\n";
	}
}
?>

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-08-23 15:52 UTC] sas at cvs dot php dot net
We are working on that
 [1999-09-15 07:12 UTC] thies at cvs dot php dot net
fixed in cvs!

 [1999-09-15 07:14 UTC] thies at cvs dot php dot net
forgot to close
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Sun Oct 11 12:00:01 2026 UTC