Connecting Tech Pros Worldwide Forums | Help | Site Map

Session with Database

Gucci
Guest
 
Posts: n/a
#1: Sep 7 '06
Some guy told me if i use database to store the session data and the
client has a low speed, the database will be kept connected until the
client agent download the webpage totally.
is that true?


Tony Marston
Guest
 
Posts: n/a
#2: Sep 7 '06

re: Session with Database


Rubbish. The database connection is closed when the process on the server
terminates (if not sooner). The server process does NOT wait for the client
to receive the output, so network speeds are irrelevant.

--
Tony Marston

http://www.tonymarston.net
http://www.radicore.org



"Gucci" <jueljust@gmail.comwrote in message
news:1157620822.208668.93700@e3g2000cwe.googlegrou ps.com...
Quote:
Some guy told me if i use database to store the session data and the
client has a low speed, the database will be kept connected until the
client agent download the webpage totally.
is that true?
>

Chung Leong
Guest
 
Posts: n/a
#3: Sep 7 '06

re: Session with Database



Gucci wrote:
Quote:
Some guy told me if i use database to store the session data and the
client has a low speed, the database will be kept connected until the
client agent download the webpage totally.
is that true?
It depends on the size of the page and the send buffer size. If there's
more data than the buffer can accommodate, then the script will stall
until some of that is transferred. The default send buffer size for
Apache is 64K I believe.

If you worry about this you can always call session_write_close() to
close the session manually instead of relying on it closing at the end
of the script.

Jerry Stuckle
Guest
 
Posts: n/a
#4: Sep 7 '06

re: Session with Database


Gucci wrote:
Quote:
Some guy told me if i use database to store the session data and the
client has a low speed, the database will be kept connected until the
client agent download the webpage totally.
is that true?
>
Probably not, but it depends on what you're doing.

For instance - if you're sending a lot of information from the database,
it's possible you'll fill the buffers and your program will have to
wait. However, that's highly unlikely.

Rather, when your page runs the output will be buffered by the web
server. If you close the connection in your code, it will be closed
immediately. If you don't close the connection, at some later time the
garbage collector will clean up and close the connection for you.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Chung Leong
Guest
 
Posts: n/a
#5: Sep 7 '06

re: Session with Database


Chung Leong wrote:
Quote:
Gucci wrote:
Quote:
Some guy told me if i use database to store the session data and the
client has a low speed, the database will be kept connected until the
client agent download the webpage totally.
is that true?
>
It depends on the size of the page and the send buffer size. If there's
more data than the buffer can accommodate, then the script will stall
until some of that is transferred. The default send buffer size for
Apache is 64K I believe.
Wait a minute, that's wrong. TCP/IP guarantees delivery. A write to
socket won't return until the data is acknowledged by the client. PHP
does buffering too, but it's flushed prior to the session closing. And
a database connection would only be destroyed at the very end of the
request handling process. So if you don't close it explicitly, it won't
be released until the page is fully transferred.

Gucci
Guest
 
Posts: n/a
#6: Sep 8 '06

re: Session with Database


i see.
the http server wouldn't run the script until it get the acknowledg by
the client.
the database is just connnected with the the http server,
so how long will it keep connecting depends on the http server.
the clinet just keeps a connection with the http server.

Chung Leong
Guest
 
Posts: n/a
#7: Sep 8 '06

re: Session with Database



Gucci wrote:
Quote:
i see.
the http server wouldn't run the script until it get the acknowledg by
the client.
the database is just connnected with the the http server,
so how long will it keep connecting depends on the http server.
the clinet just keeps a connection with the http server.
Not quite. The script won't terminate until it receives the final block
of data is acknowledged by the client. This is just a property of
TCP/IP.

To save a session in a database, you need to keep the database
connection open for the session handler to use. If you don't close the
session manually, then this means you can't close the connection within
your script, since the session is automatically saved after the script
ends. If you close the session, then you can close the connection
before you start outputing.

Closed Thread