Solved

Pass Objects all over my site

Posted on 2006-10-23
7
201 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
  • 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
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…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

856 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