PHP»á»°´¦ÀíµÄ10¸öº¯Êý

5年以前  |  阅读数:659 次  |  编程语言:PHP 

ÔÚ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Á¿¡£

 相关文章:
PHP分页显示制作详细讲解
SSH 登录失败:Host key verification failed
获取IMSI
将二进制数据转为16进制以便显示
文件下载
贪吃蛇
获取IMEI
双位运算符
发送邮件
PHP自定义函数获取搜索引擎来源关键字的方法
Java生成UUID
提取后缀名
年的日历图
在Zeus Web Server中安装PHP语言支持
让你成为最历害的git提交人
Yii2汉字转拼音类的实例代码
再谈PHP中单双引号的区别详解
指定应用ID以获取对应的应用名称
Python 2与Python 3版本和编码的对比
php封装的page分页类完整实例