Solved

Pass Objects all over my site

Posted on 2006-10-23
7
198 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses four methods for overlaying images in a container on a web page
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 a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

760 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

17 Experts available now in Live!

Get 1:1 Help Now