473,775 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Help with Serializing Objects

nathj
938 Recognized Expert Contributor
Hi,

I'm currently working on a new system and have built a number of objects for controlling data access user properties etc. I want to pass the object between pages.

The site works in the following way:
Login.php - accesscheck.php - valid credentials? - N - login.php
Login.php - accesscheck.php - valid credentials? - Y - mainpage.php

Mainpage.php will be the only page for the display of data as using AJAX I will alter this page.

When the credentials are passed to accesscheck the dataobect and userobject are instantiated and I would like to pass these on to mainpage.php.

I have read that serialization is the way to do this but I have also read a few things about this that worry me a bit.

For instance I have read that you should not serialize an object if it references itself. My objects do that using $this->propertyname .

Also the user object has an instance of the dataobject on it. So perhaps I only need to pass one of them over I don't know.

I have read a lot about this and ended up confused. So I thought I would ask for some friendly advice.

Thanks in advacne
nathj
Oct 31 '07 #1
2 1316
pbmods
5,821 Recognized Expert Expert
Heya, Nathj.

There is nothing inherently bad about serializing objects. The only bad stuff comes into play when the serialized object is accessible from the client side.

The solution is to simply store the instance in the $_SESSION. PHP will automatically serialize each object at the end of script execution and unserialize each object when you call session_start() .
Nov 27 '07 #2
nathj
938 Recognized Expert Contributor
Heya, Nathj.

There is nothing inherently bad about serializing objects. The only bad stuff comes into play when the serialized object is accessible from the client side.

The solution is to simply store the instance in the $_SESSION. PHP will automatically serialize each object at the end of script execution and unserialize each object when you call session_start() .
Thanks for the advice. I'll make sure that all my serialized objects are stored in the $_SESSION.

Cheers
nathj
Nov 27 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
332
by: Martin. D. Waller | last post by:
Hello, Does anyone kow of any good examples or documents that talk about serializing complex objects and object graphs to XML. Basically I would like to have a class that references other classes etc and I'd like to serialize the whole thing... Many thanks... Martin
0
2825
by: Tom Kent | last post by:
I have an array list of objects that I want to serialize into an XML file. I have tried this using the following code, but it gives me an error message An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dl Additional information: There was an error generating the XML document I'm not sure if this is the way that I should go about serializing an array of objects like this, but I would like to get them...
1
2088
by: Ivo Bronsveld | last post by:
All, I have quite a challenging task ahead of me. I need to write an object model (for code access) based on a schema, which cannot be made into a dataset because of it's complexity. So I created a couple of objects and serializing it into XML based upon the schema works perfectly. The XML / Schema looks something like this:
2
3522
by: Tobias Zimmergren | last post by:
Hi, just wondering what serializing really is, and howto use it? Thanks. Tobias __________________________________________________________________ Tobias ICQ#: 55986339 Current ICQ status: + More ways to contact me __________________________________________________________________
4
3621
by: Dave Veeneman | last post by:
When does serializing objects make more sense than persisting them to a database? I'm new to object serialization, and I'm trying to get a feel for when to use it. Here is an example: I'm writing an accounting application. I have a chart of accounts in the form of a containment hierarchy. A GeneralLedger contains a number of Accounts, and each of these Accounts can contain a Aubledger, which contains its own Accounts, and so on. The...
1
1135
by: Diego F. | last post by:
Hello. I hope you can help me with this. I have to write an application in C# that is more or less this: 1.- I have different clients that receive data from a central server. 2.- The server sends the initial data to the clients and keeps waiting for responses. 3.- The clients generate new data and send it back to the server to complete some operations. 4.- When the server finishes the operations requested, it sends back again the data...
6
1463
by: GrandpaB | last post by:
While writing this plea for help, I think I solved my dilemma, but I don't know why the problem solving statement is necessary. The inspiration for the statement came from an undocumented VB example I found on the web. I would be most appreciative if someone could explain why this statement is necessary and what does it do: MyArt = New Art
3
6876
by: axr | last post by:
Having trouble with Serilization of objects that contain members which are of type Interface eg public class SomeClass { ISomeInterface1 itf1; ClassType1 ct1; ISomeInterface2 itf2;
1
1315
by: Martin Widmer | last post by:
Hi guys I am wondering what is a proper way to persistently store objects into SQL-Server. I see four possible ways: 1.) Serialize to XML and then store the XML in the SQL server 2.) Write a new serializer that serializes the object by storing each attribute value into a matching field in an SQL server table while performing data type mapping and possibly compression etc... 3.) For each class write a proxy class who's objects are...
47
3121
by: Max | last post by:
Due to the behaviour of a particular COM object, I need to ensure that a request for a particular ASP page is finalized before another request for the page is processed. Does IIS have a way to ensure that subsequent requests will be queued until the current request is completed? If not, can IIS be configured to use seperate processes to satisfy requests for a nominated ASP page? Thanks in advance.
0
9622
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10109
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10051
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9916
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8939
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5486
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.