Session with Database

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gucci

    Session with Database

    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

    #2
    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

    This is Tony Marston's web site, containing personal information plus pages devoted to the Uniface 4GL development language, XML and XSL, PHP and MySQL, and a bit of COBOL

    Build apps faster with Rapid Application Development using open-source RAD tools, modern RAD frameworks, and rapid application design methods.




    "Gucci" <jueljust@gmail .comwrote in message
    news:1157620822 .208668.93700@e 3g2000cwe.googl egroups.com...
    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?
    >

    Comment

    • Chung Leong

      #3
      Re: Session with Database


      Gucci wrote:
      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_c lose() to
      close the session manually instead of relying on it closing at the end
      of the script.

      Comment

      • Jerry Stuckle

        #4
        Re: Session with Database

        Gucci wrote:
        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@attgl obal.net
        =============== ===

        Comment

        • Chung Leong

          #5
          Re: Session with Database

          Chung Leong wrote:
          Gucci wrote:
          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.

          Comment

          • Gucci

            #6
            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.

            Comment

            • Chung Leong

              #7
              Re: Session with Database


              Gucci wrote:
              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.

              Comment

              Working...