Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

PHP cookieºÍsessionµÄ·ÖÎö£¨×ª£©

1. PHPµÄCOOKIE
cookie ÊÇÒ»ÖÖÔÚÔ¶³Ìä¯ÀÀÆ÷¶Ë´¢´æÊý¾Ý²¢ÒÔ´ËÀ´¸ú×ÙºÍʶ±ðÓû§µÄ»úÖÆ¡£
PHPÔÚhttpЭÒéµÄÍ·ÐÅÏ¢Àï·¢ËÍcookie, Òò´Ë setcookie() º¯Êý±ØÐëÔÚÆäËüÐÅÏ¢±»Êä³öµ½ä¯ÀÀÆ÷Ç°µ÷Óã¬ÕâºÍ¶Ô header() º¯ÊýµÄÏÞÖÆÀàËÆ¡£
1.1 ÉèÖÃcookie:
    ¿ÉÒÔÓàsetcookie() »ò setrawcookie() º¯ÊýÀ´ÉèÖàcookie¡£Ò²¿ÉÒÔͨ¹ýÏò¿Í»§¶ËÖ±½Ó·¢ËÍhttpÍ·À´ÉèÖÃ.
1.1.1 Ê¹ÓÃsetcookie()º¯ÊýÉèÖÃcookie:
bool setcookie ( string name [, string value [, int expire [, string path [, string domain [, bool secure [, bool httponly]]]]]] )
     name:   cookie±äÁ¿Ãû
     value:   cookie±äÁ¿µÄÖµ
     expire:  ÓÐЧÆÚ½áÊøµÄʱ¼ä,
     path:    ÓÐЧĿ¼,
     domain: ÓÐЧÓòÃû,¶¥¼¶ÓòΨһ
     secure:  Èç¹ûֵΪ1,ÔòcookieÖ»ÄÜÔÚhttpsÁ¬½ÓÉÏÓÐЧ,Èç¹ûΪĬÈÏÖµ0,ÔòhttpºÍhttps¶¼¿ÉÒÔ.
Àý×Ó:
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value); /* ¼òµ¥cookieÉèÖà*/
setcookie("TestCookie", $value, time()+3600); /* ÓÐЧÆÚ1¸öСʱ */
setcookie("TestCookie", $value, time()+3600, "/~rasmus/", ".example.com", 1); /* ÓÐЧĿ¼ /~rasmus,ÓÐЧÓòÃûexample.com¼°ÆäËùÓÐ×ÓÓòÃû */
?>
ÉèÖöà¸öcookie±äÁ¿: setcookie('var[a]','value');ÓÃÊý×éÀ´±íʾ±äÁ¿,µ«ËûµÄϱ겻ÓÃÒýºÅ.ÕâÑù¾Í¿ÉÒÔÓÃ$_COOKIE[‘var’][‘a’]À´¶ÁÈ¡¸ÃCOOKIE±äÁ¿.
1.1.2. Ê¹ÓÃheader()ÉèÖÃcookie;
header("Set-Cookie: name=$value[;path=$path[;domain=xxx.com[;]]");
ºóÃæµÄ²ÎÊýºÍÉÏÃæÁгösetcookieº¯ÊýµÄ²ÎÊýÒ»Ñù.
±ÈÈç:
$value = 'something from somewhere';
header("Set-Cook


Ïà¹ØÎĵµ£º

PHP·ÖÒ³´úÂë

Í·²¿µ÷ÓÃ
 <?
require('conn.php');
$sql1="select id from news";
$query1=mysql_query($sql1,$conn);
$sun_num=mysql_num_rows($query1);
$gs=20;
$page_num=ceil($sun_num/$gs);
include("../subpage.php");
//´«¹ýÀ´µÄÒ³Êý²ÎÊý
$PB_page=$_GET['PB_page'];
if ($PB_page==1 or empty($PB_page)){
$ ......

[ת£ÝÉîÈëÀí½âPHPÖ®require/include˳Ðò


×÷Õß: laruence(http://www.laruence.com
)
±¾ÎĵØÖ·: http://www.laruence.com/2010/05/04/1450.html
תÔØÇë×¢Ã÷³ö´¦
ÔÚ´óÐ͵ÄWebÏîÄ¿ÖÐ, include_pathÊÇÒ»¸öÄ£¿é»¯Éè¼ÆµÄ¸ù±¾Öеĸù±¾(µ±È»,ÏÖÔÚÒ²Óкܶà»ùÓÚautoloadµÄÉè¼Æ,
Õâ¸ö²»Ó°Ïì±¾ÎĵÄ̽ÌÖ), µ«ÊÇÕýÊÇÒòΪinclude_path, ¾­³£»áÈÃÎÒÃÇÓöµ½Ò»Ð©ÒòΪûÓÐÕÒµ½Õ ......

phpµÄsessionÓ÷¨Ð¡½á

¡¡sessionÊÇÍøÕ¾±£´æÓû§ÐÅÏ¢µÄÒ»ÖÖÊֶΣ¬Ó¦ÓÃÏ൱¹ã·º¡£ÀýÈçµÚÎå½ìÅÅÐаñ¾ÍʹÓÃÁËsession¡£¾­¹ý¶ÔµÚÎå½ìÅÅÐаñµÄÐ޸ģ¬ÎÒ×ܽáÁËÒ»ÏÂphpÖÐsessionµÄÓ÷¨¡£
£¨Ò»£©¿ªÊ¼session
¡¡¡¡ÔÚÿһ´ÎʹÓÃsession֮ǰ£¬¶¼Òª¼ÓÉÏÕâÒ»¾ä£º“session_start();”¡£¹ËÃû˼Ò壬Õâ¸öº¯ÊýµÄ×÷ÓþÍÊÇ¿ªÊ¼Ê¹ÓÃsession¡£
£¨¶þ£©×¢ ......

phpʵÏÖµ±Ç°Óû§ÔÚÏßÈËÊý

Ô­Àí£º¸ù¾Ý²»Í¬µÄIPͳ¼Æ³öµ±Ç°ÓжàÉÙÈËÔÚÏß¡£
ʵÏÖ·½Ê½£º¿ÉÒÔÓÃÊý¾Ý¿â£¬Ò²¿ÉÒÔÓÃÎı¾¡£
ÎÒÕâÀïÓÃÁËÎı¾ÊµÏÖ¡£
<?php
/**
*@ Date         2010.04.07
*@ Author       »ªÏÄÖ®ÐÇ PHP100.com
*@ Blog      & ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ