You are here: Re: PHP Sessions « PHP « IT news, forums, messages
Re: PHP Sessions

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация