using an existing object in ajax-called php files?
Posted
by noname
on Stack Overflow
See other posts from Stack Overflow
or by noname
Published on 2010-03-21T09:37:04Z
Indexed on
2010/03/21
9:41 UTC
Read the original article
Hit count: 263
i have in my index.php created an object and set some property values.
then i use jquery ajax to call some php files and i want to use the object created.
i tried this one but it didn´t work:
---- in index.php ----
// Create a new object
session_start();
$object = new stdClass();
$object->value = 'something';
$object->other_value = 'something else';
// Save the object in the user's session
$_SESSION['object'] = $object;
---- Then in the next page that loads from AJAX ----
// Start the session saved from last time
session_start();
// Get the object out
$object = $_SESSION['object'];
// Prints "something"
print $object->value;
how do i accomplish this. cause i dont want to recreate the object in every ajaxcalled php script.
thanks in advance!
© Stack Overflow or respective owner