php3-list | 200003
Date: 03/06/00
- Next message: Chris Mason: "[PHP3] string to variable question"
- Previous message: Phil Allsopp: "Re: [PHP3] socket error~!! what's problem??"
- Next in thread: Arpad Tamas: "Re: [PHP3] session theory question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
this is purely theoretical right now but it's been bothering me.
Ok I want to assign a unique ID to visitors and store variables
pertaining to them in a MySQL database as they browse my site, before
you all tell me to use PHP4 sessions or PHPLIB, just hear me out.
The basic structure of this is:
Generate a random Session ID.
Check to see if it's already in use
if it is, start again
if it's unique then assign and you're good to go.
Now since Apache is multi-process couldn't this happen:
Process 1 randomly generates a session ID, let's say "2" (I know
that's simple but whatever).
Process 1 checks to see if "2" is already taken let's say by doing a
SELECT where id=2 and if there are any rows returned then it knows it
is taken.
Let's say Process 1 finds out that no one has taken 2 and it's ready
to move on.
BUT, right before Process 1 INSERT's "2" into the session table,
Process 2 takes control.
Process 2 also randomly generated session id "2" (of course this is
unlikely but it could happen that the same session number is
"randomly" generated close to each other, at least I have to plan
that i could happen) and checked the table and found that "2" wasn't
taken either.
So at this point both process 1 and 2 are ready to assign session ID
"2" to their respective clients. what can I do about this? any
insight would be appreciated, I think i'm missing an obvious
solution...perhaps make the session ID column a primary key and MySQL
would error when the 2nd process tries to insert it?
-aaron
-- PHP 3 Mailing List <http://www.php.net/> To unsubscribe, send an empty message to php3-unsubscribe <email protected> To subscribe to the digest, e-mail: php3-digest-subscribe <email protected> To search the mailing list archive, go to: http://www.php.net/mailsearch.php3 To contact the list administrators, e-mail: php-list-admin <email protected>
- Next message: Chris Mason: "[PHP3] string to variable question"
- Previous message: Phil Allsopp: "Re: [PHP3] socket error~!! what's problem??"
- Next in thread: Arpad Tamas: "Re: [PHP3] session theory question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

