|
Posted by Justin Koivisto on 11/11/01 11:31
Matt wrote:
> let me clarify that further.....say i've got 10 users all logged in at
> once...how do i say session 1 goes to user 1, session 2 goes to user 2
> and so on?
You don't. User 1 will only be able to see their session. That is, the
script that is running for their process only has access to one session
rather that being able to access them all. That is, unless you are using
custom session handling functions. Therefore, if you have the code below:
<?php
session_start();
if(isset($_POST['user']) && ctype_alnum($_POST['user'])){
$_SESSION['username']=$_POST['user'];
}else{
$_SESSION['username']='';
}
if(isset($_SESSION['username']) && !empty($_SESSION['username'])){
echo "Username: {$_SESSION['username']}<br />";
}else{
// no username defined in the session
}
?>
If you have 300 people post to that script at the same time, each
instance of the script will have access to only one session, preventing
any data collisions. If user 156 submitted "myUserName", then that is
all that the script running for them would have access to.
--
Justin Koivisto, ZCE - justin@koivi.com
http://koivi.com
[Back to original message]
|