Hello!

I am litle confused about this, so I hope someone could give reply on this
message an give me the right answer.

I am comfortable with the use of session, but lately when I have surf
around, I have found some documents/tutorials about saving Objects/classes
in session. It's here I am beginning to be confused. Is this for earlier
version of Php (Version 3) or what does this mean.

Is it like this:
When a user comes to my site, I intializes all the classes the site needs to
run properly, and then I serialize() the class and put them in a session
variable.
Then when the user goes to other places on my site, I only have to
unserialize() the class sessionvariable name and use the object.
EX.:
First page:
<?PHP
session_start();
require_once("A.class");
require_once("B.class");
$a = new A;
$b = new B;

$s[a] = serialize($a);
$s[b] = serialize($b);

session_register("s");

$a->do_something();
$b->do_something_else();
?>

Second Page:
<?PHP
session_start();

$a = unserialize($s[a]);
$b = unserialize($s[b]);

$a->do_something_on_page2();
$b->do_something_else_on_page2();
?>


I hope someone could give a hint on how this work.

David Tandberg-Johansen



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to