PHPͨ¹ýsession id ʵÏÖsession¹²ÏíºÍµÇ¼ÑéÖ¤[ת]
http://edu.codepub.com/2010/0131/20248.php
ÆäʵÕâ¸öÓ¦¸Ã²»ËãÊÇÒÉÄÑÎÊÌ⣬¾ÍÊÇphpÖÐÓà sessionidµÃµ½sessionµÄÖµ£¬ÒòΪµÄÈ·ºÜ¼òµ¥£¬Ö»ÊÇ¿ÉÄÜ´ó¼ÒƽʱÓò»µ½ËùÒÔûÓÐ×¢Òâµ½°ÕÁË¡£
ÏÈ˵˵£¬Õâ¸ö»úÖƵÄÓÃ;°É£¬µ½ÏÖÔÚΪֹսµØÖªµÀÕâ¸ö»úÖÆÓÐÁ½¸ö·½ÃæµÄÓÃ;£º
ÆäʵÕâ¸öÓ¦¸Ã²»ËãÊÇÒÉÄÑÎÊÌ⣬¾ÍÊÇphpÖÐÓà sessionidµÃµ½sessionµÄÖµ£¬ÒòΪµÄÈ·ºÜ¼òµ¥£¬Ö»ÊÇ¿ÉÄÜ´ó¼ÒƽʱÓò»µ½ËùÒÔûÓÐ×¢Òâµ½°ÕÁË¡£
ÏÈ˵˵£¬Õâ¸ö»úÖƵÄÓÃ;°É£¬µ½ÏÖÔÚΪֹսµØÖªµÀÕâ¸ö»úÖÆÓÐÁ½¸ö·½ÃæµÄÓÃ;£º
Ê×ÏÈ£¬¶à·þÎñÆ÷¹²ÏísessionÎÊÌ⣬Õâ¸ö´ó¼ÒÓ¦¸Ã¶¼Äܹ»Àí½âµÄ£¬µ±Ò»¸öÍøÕ¾µÄÓû§Á¿¹ý´ó£¬¾Í»áʹÓ÷þÎñÆ÷¼¯Èº£¬ÀýÈçרÃÅÓÐÒ»¸öµÇ¼ÓõķþÎñÆ÷¡£ Óû§Í¨¹ýµÇ¼·þÎñÆ÷µÇ¼֮ºó£¬µÇ¼·þÎñÆ÷±£´æÁËÓû§µÄµÇ¼ÐÅÏ¢session£¬¶øÆäËûÊÜ·ÃÎʵķþÎñÆ÷£¬ÀýÈçµçÓ°·þÎñÆ÷ûÓÐÕâ¸ösession£¬ÄÇôÎÒÃÇ¾Í ÒªÍ¨¹ýÒ»¸ösessionµÄΨһ±êʶÀ´¹²ÏíÕâ¸ösessionÁË——¾ßÌåsessionµÄ¹²Ïí³¬³öÁ˱¾Îĵķ¶Î§£¬Çë×ÔÐвéÔÄ×ÊÁÏ¡£
µÚ¶þ¸öÓÃ;¾ÍÊÇ£¬Ñé֤ͬһÓû§µÄ²»Í¬»á»°£¬Õâ¸ö±È½ÏÄÑÀí½â¡£ÕâÑù˵°É£¬Ò»¸öÓû§²¢·Çͨ¹ýä¯ÀÀÆ÷À´ÇëÇóÁ¬½Ó£¬¶øÊÇͨ¹ýsocket»òÕßÆäËü·½Ê½À´ÇëÇó Êý¾ÝµÄʱºò£¬ÎÒÃÇÊ×ÏÈÒª¶ÔËû½øÐÐÓû§µÇ¼ÑéÖ¤£¬ÑéÖ¤³É¹¦Ö®ºó£¬¾ÍÏ·¢Ò»¸ösessionid¸øËû£¬È»ºóËûÿ´ÎÇëÇóµÄʱºò¾ÍЯ´øÕâ¸ösessionid£¬ÎÒ ÃÇͨ¹ýÕâ¸ösessionidÀ´ÅжÏsessionÊÇ·ñÒѾ´æÔÚ£¬Èç¹û´æÔÚÎÒÃǾÍÈ϶¨Óû§ÒѾµÇ¼……
¶ÔÓÚµÚÒ»¸öÎÊÌ⣬ÎÒÃÇ¿ÉÒÔ°Ñsessionid±£´æÔÚÊý¾Ý¿âÖеÃÒÔʵÏÖ£¬Õâ¸ö·½·¨±È½Ï°²È«¶øÇÒÓ¦Óù㷺£¬µ«ÊDz»ÊÇÎÒÃÇÌÖÂ۵ķ¶Î§Å¶
µÚ¶þ¸öÎÊÌ⣬ÆäʵÒѾºÜ¼òµ¥ÁË£¬¿´Ò»Ï´úÂë
Ê×ÏÈÑéÖ¤µÄʱºò²úÉúÒ»¸ösessionid;
<?php
Session_start();
$sessionId
= session_id();
//µÃµ½sessionid
//½«sessionÏ·¢¸ø¿Í»§¶Ë
.........
?>
¿Í»§¶ËЯ´øsessionidÕâ¸ö±äÁ¿À´ÇëÇóÊý¾Ý
<?php
Session_id(‘
$sessionid
’);
//×¢ÒâÕâ¸öʱºòsession_id()Õâ¸öº¯ÊýÊÇ´øÓвÎÊýµÄ
Session_start();
//Õâ¸öº¯Êý±ØÐëÔÚsession_id()Ö®ºó
?>
Õâ¸öʱºòsessionÒѾÊǵǼÑé֤ʱºòµÄsessionÁË¡£
×¢Ò⣺ÔÚsessionServer.phpÖ
Ïà¹ØÎĵµ£º
×î½üÒ»Ö±ÔÚÑо¿freeBSDÏÂnginx+php+mysqlµÄ°²×°£¬¿´Á˺ܶàÍøÉϵÄ×ÊÁÏÊÕ»ñ²»Ð¡£¬²»¹ý´ó²¿·Ö¶¼ÊDZàÒë°²×°£¬Ïà¶Ô³õѧÕßÀ´Ëµ±È½Ï¸´ÔÓ£¬²»ÈÝÒ×Àí½â£¬ËùÒÔÎÒÕûºÏÁËһЩports°²×°µÄ×ÊÁÏ£¬¶¼ÊǾ¹ý×Ô¼ºÑéÖ¤ºóµÄ£¬°²×°³É¹¦Ò²±È½ÏÈÝÒ×Àí½â£¬ÏÂÃæÊÇÁ½Öֳɹ¦µÄ°¸Àý£¬ÆäÖÐÓÐÒ»¸öÊÇApache´úÌænginxµÄ°²×°£¬Ï£Íû¶Ô´ó¼ÒÓÐËù°ïÖú¡£
° ......
<?php
class Model_Data_FocusData{
....
public function getData(){...}
}
class Model_Data_IndexData{
....
public function getData(){...}
}
?>
ÓÐÕâô¼¸¸öÀ࣬ϣÍûÄܹ»×Ô¶¯µÄ¸ù¾Ý²ÎÊýÀ´µ÷Óò»Í¬µÄÀà´¦ÀíÊý¾Ý¡£
¿´µ÷ÓÃÄ£¿é£º
<?php
function getData($act){
$class = "Mode ......
dir() º¯Êý´ò¿ªÒ»¸öĿ¼¾ä±ú£¬²¢·µ»ØÒ»¸ö¶ÔÏó¡£Õâ¸ö¶ÔÏó°üº¬Èý¸ö·½·¨£ºread() , rewind() ÒÔ¼° close()¡£
Èô³É¹¦£¬Ôò¸Ãº¯Êý·µ»ØÒ»¸öĿ¼Á÷£¬·ñÔò·µ»Ø false ÒÔ¼°Ò»¸ö error¡£¿ÉÒÔͨ¹ýÔÚº¯ÊýÃûÇ°¼ÓÉÏ "@" À´Òþ²Ø error µÄÊä³ö¡£
<?php
//´ò¿ª images Ŀ¼
$dir = dir("images");
//Áгö images Ŀ¼ÖеÄÎļþ
while ......
dz̸PHPÓï·¨(1)
¡¡¡¡ÔÚÄãѧ¹ý»ù±¾µÄHTMLÓï·¨,¾Í¿ÉÒÔ±à³öÒ»¸ö¾²Ì¬µÄWebÒ³£¬¿É¶¯Ì¬½»»¥ÐÅÏ¢ÊǺÜÖØÒªµÄ¡£ÈçһЩÍøÕ¾µÄ»áÔ±ÖƵĻáÔ±×¢²á¡¢µÇ¼¶¼Ðèºó¶Ë³ÌÐòµÄÔËÐС£ºÜ¶àÍøÕ¾ËùÓõÄCGI³ÌÐòÖ÷ÒªÓÃPerl¡¢ASP¡¢Java¡¢PHP±àд£¬¶øÎÒÃÇÏÖÔÚËùÒªÓõľÍÊÇPHP¡£ËüÊÇÍêÈ«Ãâ·ÑµÄ£¬Õâ¾ÍÒª¸ÐлÄÇЩĬĬÎÞÎŵıà³ÌÈËÔ±ÁË¡£PHPµÄ½á¹¹ÀàËÆÓÚ£ ......
<?php
$connstr="DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" . realpath("data.mdb");
$connid=odbc_connect($connstr,"","",SQL_CUR_USE_ODBC);
$issuetime=date("Y-m-d H:i:s");
$sql="insert into test values("","",...)";
$result=odbc_exec($connid,$sql);
if($result) echo "successful";
else ec ......