ÔÚPHP¿ª¢ÖÐ,±ÈÆðCookie£¬Session ÊÇ´ae´¢ÔÚþÎñÆ÷¶ËµÄ»a»°£¬Ïa¶Ô°²È«£¬²¢ÇÒ²»Ïñ Cookie ÄÇÑuÓдae´¢³¤¶ÈÏÞÖÆ£¬ÕaÀiÎÒÃÇÏeϸ½eÉÜÒ»ÏÂPHP´¦Ài»a»°º¯Êý½«ÒªÓõ½10¸oº¯Êý¡£
PHP´¦Ài»a»°º¯Êý1¡¢ session_start
º¯Êý¹¦ÄÜ£º¿ªÊ¼Ò»¸o»a»°»oÕßµ»ØÒѾ´aeÔڵĻa»°¡£
º¯ÊýÔÐÍ£ºboolean session_start(void);
µ»ØÖµ£º²¼¶uÖµ
¹¦ÄÜ˵Ã÷£ºÕa¸oº¯ÊýûÓвÎÊý£¬ÇÒµ»ØÖµ¾uΪtrue¡£×iºÃ½«Õa¸oº¯ÊýÖÃÓÚ×iÏÈ£¬¶øÇÒÔÚËu֮ǰ²»ÄÜÓÐÈκÎÊa³o£¬ñÔo»a±¨¾¯£¬È磺Warning: Cannot send session cache limiter ¨C headers already sent (output started at /usr/local/apache/htdocs/cga/member/1.php:2) in /usr/local/apache/htdocs/cga/member/1.php on line 3
PHP´¦Ài»a»°º¯Êý2¡¢ session_register
º¯Êý¹¦ÄÜ£ºµÇ¼ÇÒ»¸oеıaÁ¿Îª»a»°±aÁ¿
º¯ÊýÔÐÍ£ºboolean session_register(string name);
µ»ØÖµ£º²¼¶uÖµ¡£
¹¦ÄÜ˵Ã÷£ºÕa¸oº¯ÊýÊÇÔÚÈ«¾Ö±aÁ¿ÖÐÔo¼ÓÒ»¸o±aÁ¿µ½µ±Ç°µÄSESSIONÖУ¬²ÎÊýname¾ÍÊÇÏeÒª¼ÓÈeµÄ±aÁ¿Ãu£¬³É¹¦Ôoµ»ØÂß¼Öµtrue¡£¿ÉÒÔÓÃ$_SESSION[name]»o$HTTP_SESSION_VARS[name]µÄÐÎʽÀ´È¡Öµ»o¸³Öµ¡£
PHP´¦Ài»a»°º¯Êý3¡¢ session_is_registered
º¯Êý¹¦ÄÜ£º¼i²e±aÁ¿ÊÇñ±»µÇ¼ÇΪ»a»°±aÁ¿¡£
º¯ÊýÔÐÍ£ºboobean session_is_registered(string name);
µ»ØÖµ£º²¼¶uÖµ
¹¦ÄÜ˵Ã÷£ºÕa¸oº¯Êý¿É¼i²eµ±Ç°µÄsessionÖ®ÖÐÊÇñÒÑÓÐÖ¸¶¨µÄ±aÁ¿×¢²a£¬²ÎÊýname¾ÍÊÇÒª¼i²eµÄ±aÁ¿Ãu¡£³É¹¦Ôoµ»ØÂß¼Öµtrue¡£
PHP´¦Ài»a»°º¯Êý4¡¢ session_unregister
º¯Êý¹¦ÄÜ£ºÉ¾³ýÒÑ×¢²aµÄ±aÁ¿¡£
º¯ÊýÔÐÍ£ºboolean session_session_unregister(string name);
µ»ØÖµ£º²¼¶uÖµ
¹¦ÄÜ˵Ã÷£ºÕa¸oº¯ÊýÔÚµ±Ç°µÄsessionÖ®ÖÐɾ³ýÈ«¾Ö±aÁ¿ÖеıaÁ¿¡£²ÎÊýname¾ÍÊÇÓuɾ³ýµÄ±aÁ¿Ãu£¬³É¹¦Ôoµ»Øtrue¡£
PHP´¦Ài»a»°º¯Êý5¡¢ session_destroy
º¯Êý¹¦ÄÜ£º½aÊøµ±Ç°µÄ»a»°£¬²¢Ça¿Õ»a»°ÖеÄËuÓÐ×ÊÔ´¡£
º¯ÊýÔÐÍ£ºboolean session destroy(void);
µ»ØÖµ£º²¼¶uÖµ¡£
¹¦ÄÜ˵Ã÷£ºÕa¸oº¯Êý½aÊøµ±Ç°µÄsession£¬´Ëº¯ÊýûÓвÎÊý£¬ÇÒµ»ØÖµ¾uΪtrue¡£
PHP´¦Ài»a»°º¯Êý6¡¢ session_encode
º¯Êý¹¦ÄÜ£ºsesssionÐÅÏ¢±aÂe
º¯ÊýÔÐÍ£ºstring session_encode(void);
µ»ØÖµ£º×Öu´®
¹¦ÄÜ˵Ã÷£ºµ»ØµÄ×Öu´®Öаuº¬È«¾Ö±aÁ¿Öи÷±aÁ¿µÄÃu³ÆÓeÖµ£¬ÐÎʽÈ磺a|s:12:¡±it is a test¡±;c|s:4:¡±lala¡±; aÊDZaÁ¿Ãu s:12´u±i±aÁ¿aµÄÖµ¡±it is a testµÄ³¤¶ÈÊÇ12 ±aÁ¿¼aÓÃֺš±;¡±Ö¸o¡£
PHP´¦Ài»a»°º¯Êý7¡¢ session_decode
º¯Êý¹¦ÄÜ£ºsesssionÐÅÏ¢½aÂe
º¯ÊýÔÐÍ£ºboolean session_decode (string data)
µ»ØÖµ£º²¼¶uÖµ
¹¦ÄÜ˵Ã÷£ºÕa¸oº¯Êý¿É½«sessionÐÅÏ¢½aÂe£¬³É¹¦Ôoµ»ØÂß¼Öµtrue¡£
PHP´¦Ài»a»°º¯Êý8¡¢ session_name
º¯Êý¹¦ÄÜ£º´aeÈ¡µ±Ç°»a»°Ãu³Æ
º¯ÊýÔÐÍ£ºboolean session_name(string [name]);
µ»ØÖµ£º×Öu´®
¹¦ÄÜ˵Ã÷£ºÕa¸oº¯Êý¿ÉÈ¡µÃ»oÖØÐÂÉeÖõ±Ç°sessionµÄÃu³Æ¡£ÈoÎÞ²ÎÊýnameÔo±iʾ»ñÈ¡µ±Ç°sessionÃu³Æ£¬¼ÓÉϲÎÊýÔo±iʾ½«sessionÃu³ÆÉeΪ²ÎÊýname¡£
PHP´¦Ài»a»°º¯Êý9¡¢ session_id
º¯Êý¹¦ÄÜ£º´aeÈ¡µ±Ç°»a»°±eʶºÅ
º¯ÊýÔÐÍ£ºboolean session_id(string [id]);
µ»ØÖµ£º×Öu´®
¹¦ÄÜ˵Ã÷£ºÕa¸oº¯Êý¿ÉÈ¡µÃ»oÖØÐÂÉeÖõ±Ç°´ae*ÅsessionµÄ±eʶºÅ¡£ÈoÎÞ²ÎÊýidÔo±iʾֻ»ñÈ¡µ±Ç°sessionµÄ±eʶºÅ£¬¼ÓÉϲÎÊýÔo±iʾ½«sessionµÄ±eʶºÅÉe³ÉÐÂÖ¸¶¨µÄid¡£
PHP´¦Ài»a»°º¯Êý10¡¢ session_unset
º¯Êý¹¦ÄÜ£ºÉ¾³ýËuÓÐÒÑ×¢²aµÄ±aÁ¿¡£
º¯ÊýÔÐÍ£ºvoid session_unset (void)
*µ»ØÖµ£º²¼¶uÖµ
¹¦ÄÜ˵Ã÷£ºÕa¸oº¯ÊýºÍSession_destroy²»Í¬£¬Ëu²»½aÊø»a»°¡£¾ÍÈçͬÓú¯Êýsession_unregisterÖðÒ»×¢ÏuµoËuÓеĻa»°±aÁ¿¡£