Solved

Pass Objects all over my site

Posted on 2006-10-23
7
203 Views
Last Modified: 2008-03-04
Index.php
------------

$myDoor = new door();
$myDoor->SetDoorType('single');


now, on step 2.php (or any other page)  I need $myDoor.

In this example, $myDoor->GetDoorType(); *SHOULD* return "single" no matter what page I am on.

Thanks!



0
Comment
Question by:edvinson
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
7 Comments
 
LVL 35

Accepted Solution

by:
Raynard7 earned 500 total points
ID: 17792593
The way to do this is to save everything in session variables.  This way for this login all the variables are saved across the pages

you can start your sessions with
session_start();
at the start of the page.

at the end of the page using $myDoor do something like

$_SESSION['myDoor'] = serialize($myDoor);

then when you want to use it again you would do

$myDoor = unserialize($_SESSION['myDoor']);

of cource checking if $_SESSION['myDoor'] exists

http://au.php.net/serialize

serialize and unserialize save the data that is in myDoor into a format that is saveable on disk - unserialize reinflates the data back into a class
0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17792594
oh,

an you need to include the definition for your class before you unserialize - else it does not know how to treat the data
0
 
LVL 1

Author Comment

by:edvinson
ID: 17792639
DO I EVEN NEED TO SAY IT...

PERFECT.... THANKS!

0
Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

 
LVL 1

Author Comment

by:edvinson
ID: 17792642
Congrats on topping the million point mark. That is quite an accomplishment.
0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17792644
Thankyou very much - for the points and the encouragement - 118 days ago I thought that 1million would be impossible so now i've proved its not sembee watch out (lol)
0
 
LVL 1

Author Comment

by:edvinson
ID: 17792666
One last thing, I have an open question with you. It's the LAT LONG thing.

I will be unable to test that for a few more weeks, as I am really busy on another project. If I give you the points, can you bookmark it so we can revisit it later sometime?
0
 
LVL 35

Expert Comment

by:Raynard7
ID: 17792675
ok - email me when you want to get back onto it
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Deprecated and Headed for the Dustbin By now, you have probably heard that some PHP features, while convenient, can also cause PHP security problems.  This article discusses one of those, called register_globals.  It is a thing you do not want.  …
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question