This is because $foo is local to the member functions of the class. declare global
$foo at the start of every function.
Andrey Hristov
IcyGEN Corporation
http://www.icygen.com
99%
----- Original Message -----
From: "Thomas Watson" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, August 30, 2001 12:10 PM
Subject: [PHP] Sessions in classes dosn't work!?
> How come that I cannot store a varible in the session when I do this
> from within another object?
>
> This is my code:
> ********************************************
> <?php
> session_start();
>
> class MyClass {
> function MyClass($state) {
> if($state == "page2") {
> print("[" . $foo . "]");
> session_destroy();
> } else {
> session_register("foo");
> $foo = "Hello World!";
> print("<a href=\"?state=page2\">Click here</a>\n");
> }
> }
> }
>
> new MyClass($state);
> ?>
> ********************************************
>
> /watson
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> To contact the list administrators, e-mail: [EMAIL PROTECTED]
>
>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]