Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Hi
I'm Niro, a student from sri lanka. I am stuck with some php problem. I hope you can help me with this. I'm using singleton design pattern. But im stuck with a problem.
the application is something like this.
using singleton when he enters my account page he is instanciated a logger class instance. object is created. Now its working fine.Code: Select all
$log = Logger::getInstance();
$log->Log(5);
echo "{$log->user->getUserTable()}<br>";
$_SESSION['logger'] = serialize($log);then for me i need this class object to take in the session. so what i did was serialize the object and unserialize from my next page to the same object name to retrieve it. then i call getInstance method.
Code: Select all
$blob = unserialize($_SESSION['logger']);
$blob = Logger::getInstance();
echo "{$blob->user->getUserTable()}<br>";But friend it build a new Logger instance who has an attribute called guest not the member (where i have given from the earlier page) . Means it still don't recognize the same object as its getInstance(). Pls help me to find a solution.
How does the singleton design theory really appy when you use sessions. how do we carry the object instanciated from one page and in da next page recognize as the same object. Pls reply me as sson as possible. Thank you very much.
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]