Re: Sessions in classes dosn't work!?

From: Date: Thu, 30 Aug 2001 09:14:26 +0000
Subject: Re: Sessions in classes dosn't work!?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-65186@lists.php.net to get a copy of this message
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" <w@tson.dk> To: <php-general@lists.php.net> 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: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#65186) next »