Too many Sessions in PHP

Hello !
I'm using and developing an PHP4-Website with an oracle9 database, which includes many different php-scripts. After a successfull login
on the Mainsite, a new session is created an my parameters are save in this session.
Every PHP-Site includes the lines "$session = session_id(); Session_Start();" on top. All went fine, but now I installed "XAmpp" on my computer with a new apache2 server, PHP, phpMyAdmin, ... - I think you know that.
After this installation, somethink is wrong with my session. Everytime I open a PHP-Side, a new Oracle Session is created and the ols one is NOT closed. I connect to Oracle over ADO components.
Do you have any idea what's wrong there.
Here are some Values from phpinfo.php:

oci8.default_prefetch 10 10
oci8.max_persistent -1 -1
oci8.old_oci_close_semantics 0 0
oci8.persistent_timeout -1 -1
oci8.ping_interval 60 60
oci8.privileged_connect Off Off
oci8.statement_cache_size 20 20

session.auto_start Off Off
session.bug_compat_42 On On
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 100 100
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1 PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path C:\sess C:\sess
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid Off Off

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Richard QuadlingSenior Software DeveloperCommented:
Why do you ...

$session = session_id();



The value of $session will always be an empty string as no session exists until session_start();

delphistorAuthor Commented:
You are right !
It's nonsense to do $session = session_id();  before session_start(); Because session is already started I removed session_start();
In the further script I wrote the following:

$dbconn = &NewADOConnection('oci8');
$dbh=$dbconn->Connect ....
There is NO dbconn->Close; at the end of the script. Now, when I add the line dbconn->close; it's all right. That means:
The old version of apache / php did close the existing connection itself - not the new XAmpp-version.
Why that ?

Richard QuadlingSenior Software DeveloperCommented:
How is PHP running? CGI/FastCGI/ISAPI

Different SAPIs support different persistence between requests.

It may be that you are no longer using a SAPI which supports persistent db connections.

To find out ...

<?php phpinfo(); ?>

and look for ...

Server API

near the top of the page.
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

delphistorAuthor Commented:
PHP Version 4.4.1-pl1

System  Windows NT WTS00112 5.1 build 2600  
Build Date  Nov 4 2005 00:28:28  
Server API  Apache 2.0 Handler  
Virtual Directory Support  enabled  
Configuration File (php.ini) Path  C:\Programme\xampp\apache\bin\php.ini  
PHP API  20020918  
PHP Extension  20020429  
Zend Extension  20050606  
Debug Build  no  
Zend Memory Manager  enabled  
Thread Safety  enabled  
Registered PHP Streams  php, http, ftp, https, ftps, compress.zlib  
Richard QuadlingSenior Software DeveloperCommented:

This ADO connection. Is this a COM module you are loading?

If so, it is probably just dying when your script closes. Unless you tell the object that you are finished with it, it may not know.

When you create a COM object it is owned by the caller. In this case Apache 2.0 Handler.

When your script finishes, the reference to the COM object is destroyed, but the object may not have an auto-close facility. So the COM becomes orphaned.

As you are using PHP and Oracle, why not use PHP's own Oracle commands?

From the PHP Manual ...

These functions allow you to access Oracle 10, Oracle 9, Oracle 8 and Oracle 7 databases using the Oracle Call Interface (OCI). They support binding of PHP variables to Oracle placeholders, have full LOB, FILE and ROWID support, and allow you to use user-supplied define variables.

You will need the Oracle client libraries to use this extension. Windows users will need libraries with version at least 10 to use the php_oci8.dll.

The most convenient way to install all the required files is to use Oracle Instant Client, which is available from here: » To work with OCI8 module "basic" version of Oracle Instant Client is enough. Instant Client does not need ORACLE_SID or ORACLE_HOME environment variables set. You still may need to set LD_LIBRARY_PATH and NLS_LANG, though.

Before using this extension, make sure that you have set up your Oracle environment variables properly for the Oracle user, as well as your web daemon user. These variables should be set up before you start your web-server. The variables you might need to set are as follows:

For less frequently used Oracle environment variables such as TNS_ADMIN, TWO_TASK, ORA_TZFILE, and the various Oracle globalization settings like ORA_NLS33, ORA_NLS10 and the NLS_* variables refer to Oracle documentation.

After setting up the environment variables for your webserver user, be sure to also add the webserver user (nobody, www) to the oracle group.


OCI-Collection->append - Appends element to the collection
OCI-Collection->assign - Assigns a value to the collection from another existing collection
OCI-Collection->assignElem - Assigns a value to the element of the collection
OCI-Collection->free - Frees the resources associated with the collection object
OCI-Collection->getElem - Returns value of the element
OCI-Collection->max - Returns the maximum number of elements in the collection
OCI-Collection->size - Returns size of the collection
OCI-Collection->trim - Trims elements from the end of the collection
OCI-Lob->append - Appends data from the large object to another large object
OCI-Lob->close - Closes LOB descriptor
OCI-Lob->eof - Tests for end-of-file on a large object's descriptor
OCI-Lob->erase - Erases a specified portion of the internal LOB data
OCI-Lob->export - Exports LOB's contents to a file
OCI-Lob->flush - Flushes/writes buffer of the LOB to the server
OCI-Lob->free - Frees resources associated with the LOB descriptor
OCI-Lob->getBuffering - Returns current state of buffering for the large object
OCI-Lob->import - Imports file data to the LOB
OCI-Lob->load - Returns large object's contents
OCI-Lob->read - Reads part of the large object
OCI-Lob->rewind - Moves the internal pointer to the beginning of the large object
OCI-Lob->save - Saves data to the large object
OCI-Lob->saveFile - Alias of oci_lob_import
OCI-Lob->seek - Sets the internal pointer of the large object
OCI-Lob->setBuffering - Changes current state of buffering for the large object
OCI-Lob->size - Returns size of large object
OCI-Lob->tell - Returns current position of internal pointer of large object
OCI-Lob->truncate - Truncates large object
OCI-Lob->write - Writes data to the large object
OCI-Lob->writeTemporary - Writes temporary large object
OCI-Lob->writeToFile - Alias of oci_lob_export
oci_bind_array_by_name - Binds PHP array to Oracle PL/SQL array by name
oci_bind_by_name - Binds the PHP variable to the Oracle placeholder
oci_cancel - Cancels reading from cursor
oci_close - Closes Oracle connection
oci_commit - Commits outstanding statements
oci_connect - Establishes a connection to the Oracle server
oci_define_by_name - Uses a PHP variable for the define-step during a SELECT
oci_error - Returns the last error found
oci_execute - Executes a statement
oci_fetch_all - Fetches all rows of result data into an array
oci_fetch_array - Returns the next row from the result data as an associative or numeric array, or both
oci_fetch_assoc - Returns the next row from the result data as an associative array
oci_fetch_object - Returns the next row from the result data as an object
oci_fetch_row - Returns the next row from the result data as a numeric array
oci_fetch - Fetches the next row into result-buffer
oci_field_is_null - Checks if the field is NULL
oci_field_name - Returns the name of a field from the statement
oci_field_precision - Tell the precision of a field
oci_field_scale - Tell the scale of the field
oci_field_size - Returns field's size
oci_field_type_raw - Tell the raw Oracle data type of the field
oci_field_type - Returns field's data type
oci_free_statement - Frees all resources associated with statement or cursor
oci_internal_debug - Enables or disables internal debug output
oci_lob_copy - Copies large object
oci_lob_is_equal - Compares two LOB/FILE locators for equality
oci_new_collection - Allocates new collection object
oci_new_connect - Establishes a new connection to the Oracle server
oci_new_cursor - Allocates and returns a new cursor (statement handle)
oci_new_descriptor - Initializes a new empty LOB or FILE descriptor
oci_num_fields - Returns the number of result columns in a statement
oci_num_rows - Returns number of rows affected during statement execution
oci_parse - Prepares Oracle statement for execution
oci_password_change - Changes password of Oracle's user
oci_pconnect - Connect to an Oracle database using a persistent connection
oci_result - Returns field's value from the fetched row
oci_rollback - Rolls back outstanding transaction
oci_server_version - Returns server version
oci_set_prefetch - Sets number of rows to be prefetched
oci_statement_type - Returns the type of an OCI statement
ocibindbyname - Alias of oci_bind_by_name
ocicancel - Alias of oci_cancel
ocicloselob - Alias of
ocicollappend - Alias of
ocicollassign - Alias of
ocicollassignelem - Alias of
ocicollgetelem - Alias of
ocicollmax - Alias of
ocicollsize - Alias of
ocicolltrim - Alias of
ocicolumnisnull - Alias of oci_field_is_null
ocicolumnname - Alias of oci_field_name
ocicolumnprecision - Alias of oci_field_precision
ocicolumnscale - Alias of oci_field_scale
ocicolumnsize - Alias of oci_field_size
ocicolumntype - Alias of oci_field_type
ocicolumntyperaw - Alias of oci_field_type_raw
ocicommit - Alias of oci_commit
ocidefinebyname - Alias of oci_define_by_name
ocierror - Alias of oci_error
ociexecute - Alias of oci_execute
ocifetch - Alias of oci_fetch
ocifetchinto - Fetches the next row into an array
ocifetchstatement - Alias of oci_fetch_all
ocifreecollection - Alias of
ocifreecursor - Alias of oci_free_statement
ocifreedesc - Alias of
ocifreestatement - Alias of oci_free_statement
ociinternaldebug - Alias of oci_internal_debug
ociloadlob - Alias of
ocilogoff - Alias of oci_close
ocilogon - Alias of oci_connect
ocinewcollection - Alias of oci_new_collection
ocinewcursor - Alias of oci_new_cursor
ocinewdescriptor - Alias of oci_new_descriptor
ocinlogon - Alias of oci_new_connect
ocinumcols - Alias of oci_num_fields
ociparse - Alias of oci_parse
ociplogon - Alias of oci_pconnect
ociresult - Alias of oci_result
ocirollback - Alias of oci_rollback
ocirowcount - Alias of oci_num_rows
ocisavelob - Alias of
ocisavelobfile - Alias of
ociserverversion - Alias of oci_server_version
ocisetprefetch - Alias of oci_set_prefetch
ocistatementtype - Alias of oci_statement_type
ociwritelobtofile - Alias of
ociwritetemporarylob - Alias of
delphistorAuthor Commented:
Sorry RQuadling - I was some days "out of order", so I couldn't read your last comments.
ADO-DB is not a COM-module which is loaded with php, they are serveral php-files, one of them is included in the head of my php-sites.
ADO-DB allows you, to switch to other datases without greater changes of your php-scripts. (Same kind of connection)


$DB = NewADOConnection('mysql');
could also be: NewADOConnection('oci8');

$DB->Connect($server, $user, $pwd, $db);
$rs = $DB->Execute("select * from table where key=xxx);
while (!$rs->EOF) {

Because there is no "dbconn->Close();" at the end of the the php-site(s), everytime I open or reload the php-site(s) a new ORACLE-session is created. I can see these sessions in the session-browser of "PL/SQL-Developer" or "Oracle Manager Console". The module and programmname in each session is apache.exe !!!
So I think the old apache installation could close the sessions itself, the new apache installation can't do that and I don't know why.
So I added the command "dbconn->close();" at the end of the php-sites and all went fine.

Richard QuadlingSenior Software DeveloperCommented:
Just read about ADODB. Sorry for the confusion.
PAQed with points refunded (250)

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.