Possible problem with sessions and objects...
| From: | Seth Banks | Date: | Tue, 28 Mar 2000 09:34:06 +0000 |
| Subject: | Possible problem with sessions and objects... | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-12733@lists.php.net to get a copy of this message | ||
All,
Well it seems that I have found my first PHP 4 bug! While messing around
with PHP classes and sessions I think that I have stumbled upon a rather
large problem. If this is an error in my code, lemme know, but I have tried
this various ways, and still can't get it to work. Are there known problems
with storing objects in sessions?
The problem is after I register the object in the session, start the session
on the next page, and try to access a property, it is wrong...I try and
access $auth->user on the second page, but get the value of the variable
$userid, which is a form field on the first page.
Am I completely out of my mind here, or is this a valid bug? Sorry if the
message is a bit incoherent, but it's late and I'm tired! :)
Here's a basic rundown of the code:
(from my first file (logon.php) i run this...)
require("class/auth.php");
$auth = new Auth();
$auth->user = "test";
(auth boiled down looks like this...)
class Auth {
var $user = "";
var $md5pass = "";
var $sharedValue = "";
var $auth = false;
function Auth() {
session_start();
$this->sharedValue = md5(uniqid(rand()));
$auth = $this;
session_register("auth");
}
}
(page which logon.php submits to...)
require("class/auth.php");
session_start();
$results = $auth->validate($userid, $password);