NYCPHP Meetup

NYPHP.org

[nycphp-talk] Re: Passing Objects Via Session in PHP 4

Joseph Crawford codebowl at gmail.com
Mon Sep 27 01:10:50 EDT 2004


INDEX.PHP
<?php
include_once('include/global.php');

$db = &getObject('mysql');
$db->open('localhost', 'root', '');
$db->selectDb('directory');

$tpl->display('main.tpl');

$db->test = 'this is page 1';

echo '<pre>';
print_r($_SESSION);
echo '</pre>';
$db->test = 'this is page 2';
?>

PAGE2.PHP
<?php
include_once('include/global.php');

$db = &getObject('mysql');
$db->open('localhost', 'root', '');
$db->selectDb('directory');

$tpl->display('main.tpl');

echo '<pre>';
print_r($_SESSION);
echo '</pre>';

?>

PAGE1 PRINT_R RESULTS
            [mysql] => mysql Object
                (
                    [connection] => Resource id #7
                    [test] => this is page 1
                )

PAGE2 PRINT_R RESULTS
            [mysql] => mysql Object
                (
                    [connection] => Resource id #7
                    [test] => 
                )


-- 
Joseph Crawford Jr.
Codebowl Solutions
codebowl at gmail.com
802-558-5247

For a GMail account
contact me OFF-LIST



More information about the talk mailing list