473,396 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Help with Serializing Objects

nathj
938 Expert 512MB
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 1302
pbmods
5,821 Expert 4TB
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 Expert 512MB
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
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...
0
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...
1
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...
2
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: +...
4
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...
1
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...
6
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...
3
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
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...
47
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
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...
0
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,...

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.