Class Object passed via PHP Session fails!

From: Lars Plessmann (Lars.Plessmann_at_gmx.de)
Date: 04/30/04


Date: Fri, 30 Apr 2004 19:13:06 +0200

Hello!

I try to use PHP session function, and it doesn't work properly. :-(
I want to pass a whole object from site A to site B to minimize Database
connections.

I don't use GLOBALS = ON. My param GLOBALS is set to OFF and has be be
keept off!

Well. I want to pass a complete object of class article from website A
to website B. A daily problem, I think! But it doesn't work!

Here is my Code:

-------------------------------------------------
class article
{
   var $titel;
   var $id;
   var $verkaufsart;
   var $mehrwertsteuerAusweisbar;
   var $preisart;
   var $verfügbarAb;
   var $angebotspreis;
   var $hinweise;
   var $beschreibung;

   function setTitel($titel) {
      $this->titel = $titel;
   }

   function getTitel() {
      return $this->titel;
   }

   function setId($id) {
      $this->id = $id;
   }

   function getId() {
      return $this->id;
   }
}

-------------------------------------------------
// site A
<?php

include_once 'article.php';

session_start();

$art = new article();
$art2 = new article();

session_register("art");
session_register("art2");

$art->setTitel("Test");
$art->setId("15");

$art2->setTitel("Test2");
$art2->setId("16");

print $art->getId()." ".$art->getTitel();
print $art2->getId()." ".$art2->getTitel();

print "<a href=\"step2.php\">NEXT</a>";

?>

-------------------------------------------------
// site B
<?php

include_once 'article.php';

session_start();

if (!is_object($art)) $art = new article();
if (!is_object($art2)) $art2 = new article();

print $art->getId()." ".$art->getTitel();
print $art2->getId()." ".$art2->getTitel();
....
-------------------------------------------------

By the way, when I print out the variable $_SESSION, I can see the
content of the object, but I dont have access:

Array ( [art] => article Object ( [titel] => Test [id] => 15
[verkaufsart] => [mehrwertsteuerAusweisbar] => [preisart] =>
[verfügbarAb] => [angebotspreis] => [hinweise] => [beschreibung] => )
[art2] => article Object ( [titel] => Test2 [id] => 16 [verkaufsart] =>
[mehrwertsteuerAusweisbar] => [preisart] => [verfügbarAb] =>
[angebotspreis] => [hinweise] => [beschreibung] => ) )

How is it possible, to receive the complete object via a php session on
the next site??

I hope you can help me!?

thanks in advance,

Lars



Relevant Pages

  • Re: Web Animation and Sound Advice Sought
    ... upon someone landing on my website, ... My blog program is a php program that makes use of a mysql database. ... linux (and the linux server supports all sorts of php). ... $500+ Premiere software -- at least on my first brief experimenting ...
    (misc.writing)
  • Re: Furthering my education in OOP - where/how can one learn professional skills?
    ... but I am not proud of the rather amateurish ... implement them in a website. ... is PHP the best language to use to learn and implement the full ... power of OOP? ...
    (comp.lang.php)
  • Re: Best (most Borland-like) PHP IDE+Debugger?
    ... existed before Borland quit trying to compete with M$'s VisualC. ... Is there anything like it for PHP? ... But it has no debugging capability. ... Manuel's ONLY answers to questions are to see something on his website - and he never identifies it as his website. ...
    (comp.lang.php)
  • Re: Securing PHP
    ... Does anyone here run a website of their own? ... hits with ads that you run through Google AdSense? ... What does any of this have to do with PHP? ... Yes I see a couple of spam posts get through to comp.lang.python every ...
    (comp.lang.php)
  • Re: Got Delphi for PHP - first impressions
    ... Having exactly Delphi and PHP as my two main developer platforms, ... Delphi for PHP sounded at first as a something sent from heaven. ... It looks more like normal Windows apps. ... full fledged websites, having the look and feel as a website. ...
    (borland.public.delphi.non-technical)