Solved

Pass Objects all over my site

Posted on 2006-10-23
7
199 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Consider the following scenario: You are working on a website and make something great - something that lets the server work with information submitted by your users. This could be anything, from a simple guestbook to a e-Money solution. But what…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

930 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now