PHP Session Á½ÖÖ²»Í¬´æ´¢·½Ê½
ת×Ô£ºhttp://www.cmsgp.org/article/3.html PHP SessionʹÎÒÃÇÄܹ»½«Óû§µÄÊý¾Ý±£´æÔÚ·þÎñÆ÷¶Ë¡£µ«ÊÇSessionÊý¾ÝÊÇÁÙʱµÄ£¬²¢ÇÒͨ³£µ±Óû§¹Ø±Õä¯ÀÀÆ÷ʱ£¬±£´æSession idµÄCookie¾Í»á±»É¾³ý£¬Ïà¹ØµÄSessionÊý¾ÝÒ²½«Òò´Ë¶ªÊ§¡£µ±È»£¬ÎÒÃÇ¿ÉÒÔͨ¹ýÐÞ¸Äsession.cookie_lifetimeÕâ¸ö²ÎÊýÀ´¿ØÖÆCookieÓÐЧʱ¼ä¡£
PHP SessionÔÚĬÈÏÇé¿öÏÂÊDZ£´æÔÚÎļþÖеģ¨Óë²ÎÊýsession.save_handlerÏà¹Ø£©¡£²ÎÊýsession.save_path¶¨ÒåÁËsessionÎļþµÄ·¾¶¡£ÕâЩsessionÎļþ»á±»phpÀ¬»øÊÕ¼¯Æ÷ɾ³ý¡£ËùÒÔ£¬Èç¹ûÒª±£´æһЩÓÀ¾ÃÐÔÊý¾Ý£¬ÎÒÃÇÐèÒª°ÑËüÃDZ£´æÔÚÊý¾Ý¿âÖС£
SessionÎļþ´æ´¢
ÔÚĬÈÏÇé¿öÏ£¬SessionÊDZ£´æÔÚÎļþÀïµÄ¡£ÎÒÃÇ¿ÉÒÔͨ¹ýÉèÖÃsession.save_pathÀ´Ö¸¶¨sessionÎļþµÄ·¾¶¡£ÎªÁËÄܹ»Ê¹ sessionÁÙʱÎļþ±£´æ¸ü³¤µÄʱ¼ä£¬ÎÒÃÇ¿ÉÒÔÉèÖÃÏà¹Ø²ÎÊýsession.gc_probability, session.gc_divisorºÍsession.gc_maxlifetime¡£ÕâÈý¸ö²ÎÊý¿ØÖÆÁËphpÀ¬»øÊÕ¼¯Æ÷µÄ¼¤»îƵÂʺÍSession×î´óÓÐЧʱ¼ä¡£ÀýÈ磺
session.gc_probability = 100
session.gc_divisor = 100
session.gc_maxlifetime = 1
ÔÚÕâÖÖÇé¿öÏ£¬phpÀ¬»øÊÕ¼¯Æ÷»áÔÚÿ¸öÇëÇóµ½À´Ê±±»¼¤»î£¨session.gc_probability/session.gc_divisor = 1£©¡£²¢ÇÒËùÓеÄsessionÎļþµÄÓÐЧÆÚ¶¼Îª1Ãë¡£ÕâÑùµ±ÏÂÒ»¸öÇëÇóµ½À´Ê±£¬ËùÓеÄsessionÎļþ¶¼»á±»À¬»øÊÕ¼¯Æ÷ɾ³ý¡£
×¢Ò⣺À¬»øÊÕ¼¯Æ÷µÄ¿ªÊ¼Ê±¼ä²¢²»ÊÇÄÇô׼ȷ¡£ÓÐʱ£¬SessionÎļþÒ²»áÔÚ·þÎñÆ÷É϶à´ôÒ»»á¶ù£¬ÕâͬʱҲȡ¾öÓÚ²úÉúµÄSessionÊýÁ¿¡£
SessionÊý¾Ý¿â´æ´¢
°ÑSession´æ´¢ÔÚÊý¾Ý¿âÀï¿ÉÒÔ·ÀÖ¹SessionÊý¾Ý±»À¬»øÊÕ¼¯Æ÷ɾ³ý¡£ÎÒÃÇ¿ÉÒÔͨ¹ýʹÓÃsession_set_save_handlerÀ´ÊµÏÖ¡£ÎªÁËÄܹ»´¦Àísession£¬ÎÒÃÇÐèÒª¶¨Òå»Øµ÷º¯ÊýÀ´ÏìӦһϵÁеÄsessionʼþ¡£ Session open (ÓÉsession_start()µ÷ÓÃ); Session close (ÔÚpage endʱµ÷ÓÃ); Session read (ÔÚsession_start()ºóµ÷ÓÃ); Session write (ÔÚдsessionÊý¾Ýʱµ÷ÓÃ, ͨ³£ÔÚsession closeÇ°µ÷ÓÃ); Session destroy (ÓÉsession_destroy()µ÷ÓÃ); Session garbage collect (Ëæ»úµ÷ÓÃ); 1: Mysql code:
2: CREATE TABLE sessions (ID INT NOT NULL AUTO_INCREMENT PRIMARY KEY, SessionID CHAR(26), Data TEXT DEFAULT '', DateTouched INT);
3:
4: Php code:
5: <?php
6: mysql_connect("localhost&
Ïà¹ØÎĵµ£º
»ù´¡Ìâ:
1.±íµ¥ÖÐ getÓëpostÌá½»·½·¨µÄÇø±ð?
´ð:getÊÇ·¢ËÍÇëÇóHTTPÐÒéͨ¹ýurl²ÎÊý´«µÝ½øÐнÓÊÕ,¶øpostÊÇʵÌåÊý¾Ý,¿ÉÒÔͨ¹ý±íµ¥Ìá½»´óÁ¿ÐÅÏ¢.
2.sessionÓëcookieµÄÇø±ð?
´ð:session:´¢´æÓû§·ÃÎʵÄÈ«¾ÖΨһ±äÁ¿,´æ´¢ÔÚ·þÎñÆ÷ÉϵÄphpÖ¸¶¨µÄĿ¼Öеģ¨session_dir£©µÄλÖýøÐеĴæ·Å
cookie:ÓÃÀ´´æ´¢Á¬Ðø ......
PHPµ÷ÊÔ»·¾³·Ç³£Âé·³,¶øÇÒÖÖÀàÆä¶à.ÍøÉϵÄÏà¹ØÎÄÕÂÌ«¶àÁË,µ«ÓÉÓÚʱЧµÄÎÊÌâ,²¢²»ÄÜÓÃ.
½ñÌìÕÒµ½Ò»ÆªÎÄÕÂ,ÓÚ2009Äê12ÔÂ17ÈÕ²âÊÔ¿ÉÓÃ.µ«Ê¹ÓÃPDT֮ǰ,Ðè×°JDK,¿Éµ½http://www.skycn.com/soft/3116.htmlÏÂÔØ
ÎÄÕµØÖ·:http://blog.csdn.net/yuhui_fish/archive/2009/03/29/4033397.aspx
ÄÚÈÝÈçÏÂ:
×î½üÔÚÓÃphp£¬ÅäÖúÜÂé·³£ ......
tidy ÊÇÒ»¸ö·Ç³£°ïæµÄÍøÒ³´úÂë·ÖÎöºÍ¾À´íµÄ¹¤¾ß£¬Äܹ»Ö§³Ö¶àÖÖÒ³Ãæ±àÂ룬²¢ÇÒÖ§³ÖxhtmlÊä³ö¡£Èç¹ûÎÒÃÇ͵ÀÁ£¬ÉõÖÁ¿ÉÒÔ½«Õû¸öÒ³Ã滺´æ£¬×îºó²ÉÓÃtidy´¦Àí£¬×îºóÊä³öÍêÃÀµÄxhtml´úÂë¡£
linuxÏ°²×°¹ý³ÌÈçÏ£º
Ê×ÏÈ°²×°tidy £¬ÏÂÔØtidyÔ´´úÂ룺
cvs -d:pserver: anonymous@tidy.cvs.sourceforge.net Ϊ·À±¸µç×ÓÓʼþµØÖ·ÊÕ¼¯ ......
# °²×°tidy
yum install tidy libtidy-devel
# ¸øphpÌí¼ÓtidyÄ£¿é
wget http://pecl.php.net/get/tidy-1.2.tgz
tar -xvzf tidy-1.2.tgz
cd tidy-1.2
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --libdir=/usr/lib64
make
make install
echo "extension="tidy.so"" ......
2009-08-03 16:05
|
6456´ÎÔĶÁ
|
¡¾ÒÑÓÐ2
ÌõÆÀÂÛ¡¿·¢±íÆÀÂÛ
¹Ø¼ü´Ê£ºPHP
| ¸Ðлydj9931
µÄÌṩ
|
ÊÕ²ØÕâƪÐÂÎÅ
¡¾Csdn
8ÔÂ3ÈÕ±¨µÀ¡¿PHP³ÉΪÊÀ½çÉÏ×îÁ÷ÐеĽű¾ÓïÑÔÓÐÐí¶àÔÒò£ºÁé»îÐÔ£¬Ò×ÓÃÐԵȵȡ£µ«Í¨³£Ö»ÓÃPHP»òÕßÆäËûÓïÑÔ±àÂë¾Í»áÏԵõ¥µ÷¡¢Öظ´£¬Õâ ......