hello,
i have a query that, how can i transfer an object from php file A to php file B?. but i know a solution using session.But what i need to know is, is their any other method to transfer object between php files other than session?
hello,
i have a query that, how can i transfer an object from php file A to php file B?. but i know a solution using session.But what i need to know is, is their any other method to transfer object between php files other than session?
Save in a file, save in a database, save in shared memory, save in a cache server.
One way is to store the serialized object - or its data - into a database, using the session ID as the key to "find" it again.
The same could be done using a cache file.
A faster way is using a shared memory cache like memcache. These solutions always require server-side administration and root access to set up.
Serialize the object and store in one of the following (Database,Temp,Memcache).
Depending on what the object consists of i would take a look at implementing the __sleep
and __wake
magic methods to make sure the object is able to be transferred correctly.
Hi,
by using cURL you can transfer any thing... try this..
http://php.net/manual/en/book.curl.php
The easiest way (besides using sessions) is probably to save it as an APC (Alternative PHP Cache) user variable, as you probably will install APC for opcode caching purposes already. This way you have one extension for two things.
APC stores values inmemory as Memcached does, but is way easier to install, because it's not an extra daemon running, but a PHP extension.
APC is probabaly the easiest method:
example:
// new object
$object = new ClassName('Kieran', 123);
// Store it
apc_store('object', $object);
The other script
$obj = apc_fetch('object');
print_r($obj->method());