tags:

views:

42

answers:

1

I wasn't sure if when a class is instantiated with code in PHP, if is stays in the servers cache where it would be possible to access it with ajax (php file), or if it just dies once the script finishes running.

Is it possible to do this with a Keep-Alive connection or something?

I know I'm showing my ignorance in web handle, but at the risk of looking like an idiot, I had to ask.

Thanks!

Edit: Oh, was also wanting to know, could you store an object in sessions to be accessed?

+1  A: 

You can store an object in $_SESSION, and do operations on it just like any other object (i.e.

$_SESSION['object']->method();
mwhite
IMO, this is a bad idea. Keep your session variables as light as possible. In fact, avoid sessions as much as possible.
George Marian
George, would cookies be any better? This is for admin's only, so site users wouldn't be affected by the Sessions as I'll only load them on login.
Senica Gonzalez
@Senica Gonzalez It depends on what you're doing. If it's only used for an admin interface, then it's likely acceptable. That said, one must still ask why? If it's only for an admin interface, than what's the big deal w/ instantiating that object again for the ajax call? I can't answer this question without knowing anything about the object in question.
George Marian
I agree that it's less than ideal, especially because PHP's default behavior is to store session variables to disk, but there are situations where it could be the best solution, such as when instantiating the object is expensive.
mwhite