473,326 Members | 2,061 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Persistent object sessions

Hi,

I have a that page opens an imap connection; I need to refer to the
connection across various pages. I don't want to reopen that
connection on every page (vast waste of resources).

I have tried using sessions but they do not persist objects across
pages the php manual says that too.

I have searched all websites/forums and nobody seems to bring
up/encounter this type of problem.(refer it, if i missed)

I am used to asp where we could share a connection/object across pages
in the same website or even across websites on the same server.

I know the work around's:-
1) Reopen the connection on eve page --waste of resources
2) Save it to a database or file -- to much/complex maintenance work
for something simple.

Am I missing/not understood a feature in PHP4 or is it missing this?

Thanks
Ivan
Jul 17 '05 #1
2 2184
With total disregard for any kind of safety measures
iv***********@flashmail.com (Ivan) leapt forth and uttered:
I know the work around's:-
1) Reopen the connection on eve page --waste of resources
2) Save it to a database or file -- to much/complex maintenance
work for something simple.

Unfortunatly one of the major limitations of PHP is that you cannot
store resource types such as file handles or database connections.

You do have some access to persistant connections in the form of
mysql_pconnect (http://uk.php.net/mysql_pconnect), but it comes
with some disadvantages. Taken from the user notes:
Normally you do NOT want to use mysql_pconnect. This function
is designed for environments which have a high overhead to
connecting to the database. In a typical MySQL / Apache / PHP
environment, Apache will create many child processes which lie
in idle waiting for a web request to be assigned to them. Each
of these child processes will open and hold its own MySQL
connection. So if you have a MySQL server which has a limit of
50 connections, but Apache keeps more than 50 child processes
running, each of these child processes can hold a connection to
your MySQL server, even while they are idle (idle httpd child
processes don't lend their MySQL connection to other httpd
children, they hold their own). So even if you only have a few
pages which actually connect to MySQL on a busy site, you can
run out of connections, with all of them not actually being
used.



--
Phil Roberts | Dork Pretending To Be Hard | http://www.flatnet.net/
Jul 17 '05 #2
Phil Roberts <ph*****@HOLYflatnetSHIT.net> wrote in message news:<Xn*************************@216.196.97.132>. ..
With total disregard for any kind of safety measures
iv***********@flashmail.com (Ivan) leapt forth and uttered:
I know the work around's:-
1) Reopen the connection on eve page --waste of resources
2) Save it to a database or file -- to much/complex maintenance
work for something simple.

-- One has to do the "not-so obvious" when the "obvious is not-so"
Unfortunatly one of the major limitations of PHP is that you cannot
store resource types such as file handles or database connections.
Thanks, hope we see this feature in later versions

You do have some access to persistant connections in the form of
mysql_pconnect (http://uk.php.net/mysql_pconnect), but it comes
with some disadvantages. Taken from the user notes:
Normally you do NOT want to use mysql_pconnect. This function
is designed for environments which have a high overhead to
connecting to the database. In a typical MySQL / Apache / PHP
environment, Apache will create many child processes which lie
in idle waiting for a web request to be assigned to them. Each
of these child processes will open and hold its own MySQL
connection. So if you have a MySQL server which has a limit of
50 connections, but Apache keeps more than 50 child processes
running, each of these child processes can hold a connection to
your MySQL server, even while they are idle (idle httpd child
processes don't lend their MySQL connection to other httpd
children, they hold their own). So even if you only have a few
pages which actually connect to MySQL on a busy site, you can
run out of connections, with all of them not actually being
used.

Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Felix E. Klee | last post by:
I've set up a PHP web application where users can log in and open a connection to a NNTP-server. There is a *one-to-one* relationship between sessions and NNTP-connections (i.e. exactly one...
16
by: Paul Rubin | last post by:
I've had this recurring half-baked desire for long enough that I thought I'd post about it, even though I don't have any concrete proposals and the whole idea is fraught with hazards. Basically...
1
by: brad | last post by:
Hi, Im using classic ASP (3.0) and I have a web farm with 2 webservers (webserver A and webserver B, both windows server 2003). I do not want to store any client specific information on the...
8
by: Steve | last post by:
Can anyone tell me the preferred method for writing and retrieving persistent information using .Net. Specifically, I am referring to information that you used to see in registry keys or .ini...
4
by: keegan.csmith | last post by:
Hi, I have started a new small web project, and was wondering if there are any good guides on how to do Persistent Sessions and Authentication using python and CGI. I don't really want too use...
2
by: howachen | last post by:
Hi, Are there something like a `Persistent global variable` in PHP? It is something like `Application` in the classic ASP, all the request share the same variable, and the die after a timeout.
3
by: Arnost Sobota | last post by:
Dear ASP community, I have a question regarding ASP session variables. My assumption was that a session variable has the same lifetime as the session itself: as a consequence, given that...
3
by: sanchita | last post by:
Hello everyone, I didn't get any response in "Security" forum hence posting here again. I am having problem with persistent cookies. Even after setting "CreatePersistentCookie" to true in...
3
by: cjhegarty | last post by:
Hello, I have an application which runs on a single linux box, with a C++ backend server and a web-based front end, with apache also running on the local server. I'm using PHP to communicate...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.