Wrox Home  
Search P2P Archive for: Go

  Return to Index  

pro_php thread: How do i access objects, once created, all across the project ?


Message #1 by "Amit " <amit_a_deshpande@r...> on 21 Aug 2001 13:43:28 -0000
Hi dudes,

Finally i got how to access object globally using sessions.
1) In every file that u want to access that object, u must include objec
t definition file.
include ("myClass.inc")

2) U *must* start a session and register that object in session using ses
sion_register("myObject"), *before* creating an instance of the class
===============
page1.php
===============
session_start();
session_register("myObject");

$myObject = new MyClass();
$myObject->setX("100");
header("location:/page2.php");


===============
page2.php
===============
include ("myClass.inc")

session_start();

$myObject->setY("50");
header("location:/page3.php");



===============
page3.php
===============
include ("myClass.inc")

session_start();

echo $myObject->getX();
echo $myObject->getY();



In page3.php i do get values as 100 and 50 respectively.

Thanks to all.
Have a nice week end :)

Amit 







  Return to Index