Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #10950
| From | Lew Pitcher <lew.pitcher@digitalfreehold.ca> |
|---|---|
| Subject | Re: multiple visitors at the same time |
| Newsgroups | comp.lang.php |
| References | <39cy6hpu04oe$.18k40zgdny9go$.dlg@40tude.net> |
| Organization | The Pitcher Digital Freehold |
| Message-ID | <nso2u.137$Bi.115@fx17.iad> (permalink) |
| Date | 2013-09-30 20:13 -0400 |
On Monday 30 September 2013 18:12, in comp.lang.php, "richard"
<noreply@example.com> wrote:
> I kind of realized i now have another problem to deal with.
> As I have it set up, when a visitor enters, that creates a playlist for
> that visitor.
> What happens when another visitor is online?
> I tried it with both IE and FF at the same time.
> While the list is dffierent, there is no audio in the second browser.
>
> So I figure I will have to give each browser a unique id to the playlist.
> But how?
At the beginning of the webpage, before /anything/ has been sent to the
client, have your PHP code execute a session_start() call. Note that this
*absolutely must* be the first thing done; if you send out even one blank
line, this does not work.
session_start() generates a cookie, records the cookie identifier on the
server side, and sends the cookie to the client in the HTTP headers.
Because the cookie has to go out in the headers, you cannot send any data
before it.
Now, in your page's body PHP, you can test certain values that PHP provides
that all relate to that cookie. The easiest way is to check the existance
and contents of the $_SESSION associative array.
$_SESSION will be null (as will any keyed $_SESSION value) on the client's
initial entry to the page. Thus, an isset() test within the body will be
able to determine if the client has retrieved the initial page, or has
retrieved a second or subsequent time.
As $_SESSION is an associative array, you can store values in it. Each time
the client returns and rereads the page, you get the values /for that
client/ as values of $_SESSION.
So, your logic might look something like
if (isset($_SESSION['RowNum'])
{
/* RETURNING CLIENT
$_SESSION['RowNum'] is last row shown to the client, so
start his listing at database result row (1 + $_SESSION['RowNum'])
*/
$StartRow = 1 + $_SESSION['RowNum'];
/* generate next result set, from row $StartRow to $EndRow */
$_SESSION['RowNum'] = $EndRow;
}
else
{
/* NEW CLIENT
$_SESSION['RowNum'] is not set.
start his listing at database result row 0
*/
$StartRow = 0;
}
$EndRow = ComputeEndRow($StartRow);
GeneratePartialResultSet($StartRow, $EndRow);
/* save the session's start row for next time */
$_SESSION['RowNum'] = $EndRow;
....
> Would the server crash with s few thousand visitors online at the same
> time?
It depends on how you've configured your server. If you have your http
server set up to handle a large number of connections, and enough temporary
space for a large number of session state records (saved as small files),
and have configured the database server for the large number of database
connections, you should have no problem servicing thousands of simultaneous
clients.
[snip].
--
Lew Pitcher
"In Skills, We Trust"
PGP public key available upon request
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
multiple visitors at the same time richard <noreply@example.com> - 2013-09-30 18:12 -0400
Re: multiple visitors at the same time Michael Vilain <vilain@NOspamcop.net> - 2013-09-30 16:16 -0700
Re: multiple visitors at the same time richard <noreply@example.com> - 2013-09-30 19:23 -0400
Re: multiple visitors at the same time Michael Vilain <vilain@NOspamcop.net> - 2013-09-30 20:37 -0700
Re: multiple visitors at the same time Jerry Stuckle <jstucklex@attglobal.net> - 2013-10-01 06:15 -0400
Re: multiple visitors at the same time Richard Damon <Richard@Damon-Family.org> - 2013-10-01 08:05 -0400
Re: multiple visitors at the same time Christoph Michael Becker <cmbecker69@arcor.de> - 2013-10-01 18:02 +0200
Re: multiple visitors at the same time Jerry Stuckle <jstucklex@attglobal.net> - 2013-10-01 12:09 -0400
Re: multiple visitors at the same time Richard Damon <Richard@Damon-Family.org> - 2013-10-02 23:33 -0400
Re: multiple visitors at the same time Scott Johnson <noonehome@chalupasworld.com> - 2013-10-03 05:27 -0700
OT Re: multiple visitors at the same time Twayne <nobody@spamcop.net> - 2013-10-03 14:00 -0400
Re: OT Re: multiple visitors at the same time Scott Johnson <noonehome@chalupasworld.com> - 2013-10-03 16:13 -0700
Re: multiple visitors at the same time Lew Pitcher <lew.pitcher@digitalfreehold.ca> - 2013-09-30 20:13 -0400
Re: multiple visitors at the same time Fiver <numeralfive@gmail.com> - 2013-10-01 05:30 +0200
Re: multiple visitors at the same time Norman Peelman <npeelman@cfl.rr.com> - 2013-10-01 07:04 -0400
Re: multiple visitors at the same time Denis McMahon <denismfmcmahon@gmail.com> - 2013-10-01 20:48 +0000
Re: multiple visitors at the same time Knocker <knock_yourself_out@example.net> - 2013-10-04 01:02 +0000
Re: multiple visitors at the same time Twayne <nobody@spamcop.net> - 2013-10-04 19:19 -0400
csiph-web