473,473 Members | 1,589 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Class Object passed via PHP Session fails!

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
Jul 17 '05 #1
6 1832
Lars Plessmann <La************@gmx.de> wrote:
I don't use GLOBALS = ON. My param GLOBALS is set to OFF and has be be
keept off!
[your code] session_register("art");
session_register("art2");
Please read the first Caution on the session_register page:
<q>
Caution

If you want your script to work regardless of register_globals, you need
to instead use the $_SESSION array as $_SESSION entries are
automatically registered. If your script uses session_register(), it
will not work in environments where the PHP directive register_globals
is disabled.
</q>
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!


What is your definition of website? Normally websites don't share
sessions.

BTW your solution might be serialize:
http://nl2.php.net/manual/en/languag...ialization.php

--

Daniel Tryba

Jul 17 '05 #2
Daniel Tryba wrote:
Lars Plessmann <La************@gmx.de> wrote:
I don't use GLOBALS = ON. My param GLOBALS is set to OFF and has be be
keept off!

[your code]
session_register("art");
session_register("art2");

Please read the first Caution on the session_register page:
<q>
Caution

If you want your script to work regardless of register_globals, you need
to instead use the $_SESSION array as $_SESSION entries are
automatically registered. If your script uses session_register(), it
will not work in environments where the PHP directive register_globals
is disabled.
</q>


Well. how can I share an object then (with class definition and so on)?
I don't like to use the $_SESSION[] var.
I like to use the $obj->property form.
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!

What is your definition of website? Normally websites don't share
sessions.


I want to read some records from a database (articles) and display them
on click in detailled version. I don't want to make another slq request
so i think its better to load the articles an keep them in memory.

BTW your solution might be serialize:
http://nl2.php.net/manual/en/languag...ialization.php

Jul 17 '05 #3
In article <c6*************@news.t-online.com>,
Lars Plessmann <La************@gmx.de> wrote:
I don't like to use the $_SESSION[] var.
I like to use the $obj->property form.


You can still use $_SESSION['art']->property. If that doesn't look
aesthetically pleasing to you, you can always do this, I suppose:

$obj =& $_SESSION['art'];

and use the $obj->property form.

JP

--
Sorry, <de*****@cauce.org> is een "spam trap".
E-mail adres is <jpk"at"akamail.com>, waarbij "at" = @.
Jul 17 '05 #4
Lars Plessmann <La************@gmx.de> wrote:
Well. how can I share an object then (with class definition and so on)?


Thank you for not reading the pointers I gave you.
BTW your solution might be serialize:
http://nl2.php.net/manual/en/languag...ialization.php


Hint hint, read this page...

--

Daniel Tryba

Jul 17 '05 #5
Daniel Tryba wrote:
Lars Plessmann <La************@gmx.de> wrote:
Well. how can I share an object then (with class definition and so on)?

Thank you for not reading the pointers I gave you.

BTW your solution might be serialize:
http://nl2.php.net/manual/en/languag...ialization.php

Hint hint, read this page...


Ohh. sorry. I didn't see the link. I thought it was part of the
signature. :)
Thx!
Jul 17 '05 #6
Lars Plessmann <La************@gmx.de> wrote:
BTW your solution might be serialize:
http://nl2.php.net/manual/en/languag...ialization.php

Hint hint, read this page...


Ohh. sorry. I didn't see the link. I thought it was part of the
signature. :)


Oh well, you solved you problem :)

BTW fancy newsreaders can do all kind of stuff like give different
colors to sigs

--

Daniel Tryba

Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Tammy B. | last post by:
Hiya - Big puzzler for me. Code Below I create a class. I save it to a session variable. Then, I retrieve the session variable back into a new local variable. I am able to use a method which...
4
by: Vedanta Barooah | last post by:
greetings.... in a python nested class is it possible to change the value of the parent class's variable without actually creating an instance of the parent class, consider this code: class...
2
by: Earl Teigrob | last post by:
I am programming ASP.NET using C#. I have been accessing static variables accross my entire application but now need to change some of the static variables that are session specific to instance...
6
by: Scott Zabolotzky | last post by:
I'm trying to pass a custom object back and forth between forms. This custom object is pulled into the app using an external reference to an assembly DLL that was given to me by a co-worker. A...
1
by: Martin | last post by:
Hello Group I'm having a bit of trouble figuring this out. I'm grateful for any hints. Let's assume I'm have a webapplication with two .aspx pages, Page A and Page B. Page A consists of a...
2
by: John Mullin | last post by:
We are having a problem which appears similar to a previous posting: http://groups.google.com/groups?hl=en&lr=&frame=right&th=d97f552e10f8c94c&seekm=OZw33z9EDHA.2312%40TK2MSFTNGP10.phx.gbl#link1 ...
2
by: Chris Puncher | last post by:
Hi. I have a RCW class that was generated by the VS.NET2003 IDE when I added a COM dll reference to my project. This all works fine when I call methods on it. My initial problem is that in...
4
by: Diffident | last post by:
Hi All, I am trying to perform a non-CPU bound operation in an asynchronous fashion using 'Thread' and a delegate. Basically, I am spawning a thread using ThreadStart and Thread. My non-CPU...
8
by: carrion | last post by:
Hello everyone! I'm currently working on a MVC-framework and have run into an issue. I'm using separate script files to render the active page's CSS and Javascript Code. I want to pull the data...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.