RE: [PHP4BETA] Possible problem with sessions and objects...
| From: | Seth Banks | Date: | Wed, 29 Mar 2000 05:15:41 +0000 |
| Subject: | RE: [PHP4BETA] Possible problem with sessions and objects... | ||
| References: | 1 | Groups: | php.version4 |
| Request: | Send a blank email to php-version4+get-12785@lists.php.net to get a copy of this message | ||
So can someone confirm that you can/can't register objects within a session
and have them work properly? Is this a bug or am I being ignored? :)
- seth
-----Original Message-----
From: pour@mieterra.com [mailto:pour@mieterra.com]
Sent: Tuesday, March 28, 2000 1:55 PM
To: Seth Banks
Subject: Re: [PHP4BETA] Possible problem with sessions and objects...
Hi,
Unless this has changed recently, you cannot session-register objects,
only arrays and scalars.
Ciao,
Andreas
Seth Banks wrote:
>
> 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);
>
> --
> PHP 4.0 Beta Mailing List <http://www.php.net/version4/>
> To unsubscribe, e-mail: php4beta-unsubscribe@lists.php.net
> For additional commands, e-mail: php4beta-help@lists.php.net
> To contact the list administrators, e-mail: php4beta-admin@lists.php.net