Reply to Re: Passing an Object via Session

Your name:

Reply:


Posted by Oli Filth on 10/14/05 18:14

jimbojones230@gmail.com said the following on 13/10/2005 21:20:
> Hello,
>
> I'm attempting to pass all of the current values of an object to a new
> page using sessions. This is basically the code I've tried:
>
> page1.php
>
> <?php
> session_start();
> include "class.php";
> $object = new Class();
> $object->function();
> $_SESSION['object']=$object;
> ?>
>
> page2.php
> <?php
> session_start();
> include "class.php";
> $object = $_SESSION['object'];
> $object->function();
> ?>
>
> Can anyone tell me what I'm doing wrong, or if it's even possible to
> send an object using sessions? I get a fatal error when it tries to
> call the function on the second page.
>

You need to put the include "class.php" before session_start().
session_start() reinitialises the variables, and therefore needs the
class definitions to be able to do that.


--
Oli

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация