php-windows Digest 13 Oct 2005 00:32:12 -0000 Issue 2794
Topics (messages 26401 through 26402):
Re: Handling objects as session vars
26401 by: Paul Menard
How to advise a script to always execute or be included?
26402 by: Ross Honniball
Administrivia:
To subscribe to the digest, e-mail:
[EMAIL PROTECTED]
To unsubscribe from the digest, e-mail:
[EMAIL PROTECTED]
To post to the list, e-mail:
[email protected]
----------------------------------------------------------------------
--- Begin Message ---
Marcos,
A suggestion to your code changes.
<?phphpinclude("class/object_def.phphp;
session_start();
// First check the $_SESSION for a previous instance of your object
if (!isisset_SESSION['session_object']))
{
$_SESSION['session_object'] = new TNTNewClasscod,$password);
}
?>
Try this first. Note I removed the 'if' statement where you were checking for a
valid object
instance. I suggest using the PHPHPunction 'is_a' and/or 'is_object'.
Start with this...
David,
This is not a correct statement "sessions work by using cookies, and cookies
can't take
phphpbjects".
In PHPHPhe session information is not pushed to the user's browser in a cookie.
Only a reference
to the session is stored in a cookie on the user's side. The actual content of
the session is
written to a file on the server.
--- David Collard <memeizawotmeizmgmailom> wrote:
> Marcos R. CaCardosorote:
>
> i'i'dry using serialize() to turn the object into a string which can
> then be put in the session, and then ununserialize when you want it back
> out again
>
> sessions work by using cookies, and cookies can't take phphpbjects
>
> ;)
>
> > I'm trying to use an object as a session var so I could handle its
> > properties and methods as long as the session is still on. But when I
> > use a second PHPHPcript the values inside this object are lost. I have
> > a script like this.
> >
> > <?
> > include("class/object_def.phphp;
> > session_start();
> > $new_object = new TNTNewClasscod,$password);
> > if ($new_object->gegetCod == 0) {
> > echo $new_object->gegetMsgError;
> > } else {
> > $_SESSION['session_object'] = $new_object;
> > ?>
> > <script language="JaJavaScript
> > location.replace("new_script.phphp;
> > </script>
> > <?
> > }
> > ?>
> >
> > then in the script "new_script.phphpI have the following instructions:
> >
> > <?
> > include("class/object_def.phphp;
> > session_start();
> > if ($_SESSION['session_object'] == "") {
> > echo "there is no session open<brbr;
> > exit;
> > }
> > echo $_SESSION['session_object']->gegetCod."<brbr;
> > echo $_SESSION['session_object']->gegetName."<brbr;
> > ?>
> >
> > The result from the script new_script.phphplways return empty where
> > the methods should return something. I've already read the
> > documentation at wwwwwhphpet, tried what it's shown there and checked
> > some other sites as well, bu I haven't found a solution yet.
> >
> > Environment:
> >
> > Windows 2003 Server
> > Apache 2.0.54
> > PHPHP.4.0
> > Sun Chili!Soft ASP 3.6.2
> > MyMySQL.0.20a
> > Oracle 9i (through a Oracle 8i NeNetClient
> >
> >
> > TIA,
> > Marcos R. CaCardoso> > BlBlumenau> > Brazil
> >
>
> --
> PHPHPindows Mailing List (hthttp/wwwwwhphpet/)
> To ununsubscribevisit: hthttp/wwwwwhphpet/ununsubhphp>
>
--- End Message ---
--- Begin Message ---
How do you advise a script to always execute or be included before each script
is run?
I can remember reading that this was an option years ago and want to use it now
but I'm having trouble finding it in the manual.
Thanks ... Ross
--- End Message ---