Hi,
I'm currently building an object-oriented shopping cart with PHP 4.3.2 and
MySQL 4.0.14.
I am looking at storing a Cart object within a PHP session, however I am not
completely sure on the best way to achieve this. I have read up and there
seems to be varying advice. Should I need to serialise and unserialise the
object or is this automatic and should I be using session_registe r()? For
reference, register_global s is off.
I'd be grateful if anybody could help.
Thanks in advance,
Matt 3 4020
"Matthew Bates" <ma********@hot mail.com> wrote in message
news:bz******** *************@n ews-text.cableinet. net... Hi,
I'm currently building an object-oriented shopping cart with PHP
4.3.2 and MySQL 4.0.14.
I am looking at storing a Cart object within a PHP session, however
I am not completely sure on the best way to achieve this. I have read up and
there seems to be varying advice. Should I need to serialise and
unserialise the object or is this automatic and should I be using
session_registe r()? For reference, register_global s is off.
I'd be grateful if anybody could help.
With your version of PHP, you wouldn't want to use session_registe r()
since it's deprecated.
This also means, your objects are not (un)serialised automatically. So
you'd want to do something like:
At the start of the page:
- include the class (since serialized objects do not contain the class
functions)
- start the session (this must be after the class include)
- unserialize the object
At the end of the page:
- serialize the object
For more info http://php.net/manual/en/language.oop.serialization.php
On Tue, 2 Sep 2003 02:04:43 +0800, "powerboy"
<po******@rarex treme.com> wrote: "Matthew Bates" <ma********@hot mail.com> wrote: I'm currently building an object-oriented shopping cart with PHP4.3.2 and MySQL 4.0.14.
Should I need to serialise and unserialise the object or is this automatic and should I be using session_registe r()? For reference, register_global s is off.
This also means, your objects are not (un)serialised automatically.
At the start of the page: - include the class (since serialized objects do not contain the class functions) - start the session (this must be after the class include) - unserialize the object
At the end of the page: - serialize the object
For more info http://php.net/manual/en/language.oop.serialization.php
my experience agrees with what the first comment on that page is:
objects are automatically (un)serialized when putting in and getting
out of a session.
if you have resources in your object (like a database connection), you
may want to look at __sleep and __wakeup to shut down and restore them
properly.
Matthew Bates schrieb: Hi,
I'm currently building an object-oriented shopping cart with PHP 4.3.2 and MySQL 4.0.14.
I am looking at storing a Cart object within a PHP session, however I am not completely sure on the best way to achieve this. I have read up and there seems to be varying advice. Should I need to serialise and unserialise the object or is this automatic and should I be using session_registe r()? For reference, register_global s is off.
I'd be grateful if anybody could help.
Thanks in advance, Matt
With your PHP version, storing objects in the session should work quite
easy - just set
$_SESSION["cart"] = $your_card_obje ct;
i.e., no serizalize/unserialize is necessary.
One problem may occure when you will retrive the object from the session
- you need to include the class definition before the session starts!
But I found it easier to store only object IDs in the session and to
store/retrieve the object itself from the database.
Regards!
Rainer
--
------------------------------------------------
Rainer Herbst Linux - Registered
ZEIK User #319157
Universität Potsdam Usual disclaimers applies!
------------------------------------------------ This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Yoyoma_2 |
last post by:
Hello, i'me having a wierd problems with sessions.
PHP 4.3.3, Register globals is on, and the sessions module is installed.
if i have a page like this:
<?
session_start();
$_SESSION="blue";
?>
On the next page i can see that $_SESSION is actually equal to
|
by: Gary W |
last post by:
Hello,
I have used SESSIONS on mission critical pages on my site, and if sessions
are not enabled / supoorted - these pages will fail.
When and why would a session fail? They do not store any info client side,
and rely on the server to store session objects in memory, am I correct?
Would security settings or privacy controls ever stop sessions working?
Which "popular" browsers dont support sessions?
|
by: Maxime Ducharme |
last post by:
Hi group
We have a problem with sessions in one of our sites.
Sessions are used to store login info & some other infos
(no objects are stored in sessions).
We are using Windows 2000 Server (IIS 5.0) with
ASP 3.0 (no .NET on this site).
Sometime, data in session is emptied. I say "sometime"
|
by: jty202 |
last post by:
1. Can I have an array of objects as sessions variable in other words
sessions array-of-objects? If so how?
2. Besides Sessions variable what else can I use to store large amount of
data temporarily thats related to the current user.
( can I use temp files? and instead of storing the large text data in a
sessions variable or arrays, I could store the temp-file names which
contains the large text data? )
|
by: Miguel |
last post by:
Hi all friends:
It's said that Sessions objects in ASP 3.0 with IIS 5.0 occupy certain memory of the machine which take to take care about use a lot of Sessions objects in the ASPs pages of the applications.
So my question is about how recommendable is to use a lot of Sessions objects in ASP.Net I want to use in my application 30 of this objects. Im gonna use them for give permissions to the users of the application.
Regards.
| |
by: Daniel Walzenbach |
last post by:
Hi,
I have a web application which sometimes throws an “out of memoryâ€
exception. To get an idea what happens I traced some values using performance
monitor and got the following values (for one day):
\\FFDS24\ASP.NET Applications(_LM_W3SVC_1_Root_ATV2004)\Errors During
Execution: 7
\\FFDS24\ASP.NET Apps v1.1.4322(_LM_W3SVC_1_Root_ATV2004)\Compilations
|
by: Sebastian Araya |
last post by:
Hello,
I'm facing a little problem with php 5.1 and SOAP sessions. I've
built a class which uses a few internal objects to solve a query, named
CWebService, and I've issued a:
$objServer = new SoapServer( 'WebService.wsdl' );
$objServer->setClass( 'CWebService' );
|
by: Atul |
last post by:
Hi,
I am running .NET Framework 2.0 on windows XP SP2. I am stuck in a situation
where I need to find out a list of all active sessions running in IIS for a
web application.
I know that .NET 2.0 has introduced a new class that facilitate this task
very easily, somehow couldnt recall its name.
Any help would be highly appreciated.
|
by: AlonR |
last post by:
Hi,
We're experiencing random user sessions losses on our web applications,
and are researching for any useful information which may shed light on
this problem.
Environment:
In our company, we're developing a web product based on ASP.NET 2.0, in
conjunction with Oracle database over ADO.NET and external COM objects
|
by: Frinavale |
last post by:
One of the most fundamental topics in web design is understanding how to pass information collected on one web page to another web page. There are many different ways you could do this: Cookies, Database... However, I'm going to cover how to use Sessions.
Sessions are used to store information in order to use it during later page requests or in other web pages in a web application. By default Cookies are used to identify which session...
|
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,...
| |
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...
|
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,...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
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...
| |