You are here: need session_start() to recall session data. « PHP « IT news, forums, messages
need session_start() to recall session data.

Posted by "Matt Monaco" on 12/03/05 20:28

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();
}

$class = get_class($object);
$_SESSION["cmsSessionArray"][$class] = serialize($object);
}

static function unpack($strObject)
{
session_start();
return unserialize($_SESSION["cmsSessionArray"][$strObject]);
}

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.)

Are session supposed to work this way?

 

Navigation:

[Reply to this 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

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