Reply to Re: [PHP] need session_start() to recall session data.

Your name:

Reply:


Posted by "Matt Monaco" on 12/03/05 21:57

Yes, I actually changed the destructors to handle the session as you
indicated a few minutes after I posted, however I still have no clue as to
why I would need to do a session_start() to get data from the session.


"Curt Zirzow" <czirzow@gmail.com> wrote in message
news:20051203193119.GD5243@bagend.shire...
> On Sat, Dec 03, 2005 at 01:28:21PM -0500, Matt Monaco wrote:
>> I have the following two methods as part of a class I'm using to
>> transport
>> data between pages.
>>
>> static function pack($object)
>> {
>> if (session_id() == "") {
>> session_start();
>
> I wouldn't put a random session_start() in places like this.
>
>> }
>>
>> $class = get_class($object);
>> $_SESSION["cmsSessionArray"][$class] = serialize($object);
>> }
>> ...
>>
>> the pack() method is called by the destructor of the objects I want to
>> save
>> like:
>> function __destruct()
>> {
>> parent::pack($this);
>> }
>>
>
>> On subsequent pages the session data is not available until I do a
>> session_start(). Regardless of the fact that I think the session
>> shouldn't
>> need to be restarted, I don't like the fact that if indeed it has been
>> closed that a session_start() on another page will bring back the data.
>> (Note, fortunately this doesn't not occur if the browser window has been
>> closed, at that point all session data is definitely lost as expected.)
>
> I'm not sure what you mean by restarting a session or what 'indeed
> has been closed'
>
> btw, your pack and unpack aren't really needed. All you have to do
> is in your __destruct() function is put something like:
>
> $_SESSION['cmsSessionArray'][__CLASSNAME__] = $this;
>
> And when you pull it out of the session:
> $obj = $_SESSION['cmsSessionArray']['someClass'];
>
> You'll have an instance of that class; you're really causing more
> work than needed.
>
> Curt.
> --
> cat .signature: No such file or directory

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация