PHP4, session vars, and database connections
| From: | Dan Kalowsky | Date: | Mon, 11 Sep 2000 21:09:33 +0000 |
| Subject: | PHP4, session vars, and database connections | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-32962@lists.php.net to get a copy of this message | ||
PHP 4.0.2 release, running on FreeBSD 4.1-STABLE, Solid database 3.5
I create a session using session_start() and within that session
register a variable called sDatabase. sDatabase is a class which
contains a connection to our database. this connection works fine, and
is done using an odbc_pconnect().
all database functions seem to work fine on that page, but upon moving
to a second page all is not well. the session is started again, and I
have checked to make sure that the session id is fine between the two.
all the class "private" variables are still valid between the pages, but
the database connection is gone.
the db connection is being done over a tcp connection to localhost on
port 1313.
so i've setup ethereal to watch the traffic. interesting point of note
is that the first initial page will make the db connection, and do any
query statements we want. the second page, never once seems to try the
connection, suggesting that somehow the connection was closed.
looking through the php_odbc.c it seems that everything is being done
properly, but the session code has me a little off base, hence the
posting.
the questions:
is this normal behavior?
if not, is anyone more familiar with the session var system able to
assist in correcting this?
if it is, why?
While this might seem to been a question better suited to the
php-general forum, I decided that it really wasn't after looking at some
of the code...sorry if you disagree.
--
Dan Kalowsky "Tonight I think I'll walk alone,
Worldgate Communications I'll find my soul as I go home."
Software Engineer - TICS Group - Temptation