ÔõôʹÓÃthinkphp5ɨ³ýsession
Ò»¡¢session µÄ»ù±¾¿´·¨
session ÊÇʲôÄØ£¿¼òÆÓÀ´Ëµ£¬session ÊÇÒ»ÖÖЧÀÍÆ÷¶ËµÄ´æ´¢ÊÖÒÕ£¬¿ÉÒÔ½«Óû§µÄÊý¾ÝÉúÑÄÔÚЧÀÍÆ÷¶Ë¡£session µÄÊÂÇéÔÀíÈçÏ£º
µ±Óû§µÚÒ»´Î»á¼ûÍøվʱ£¬Ð§ÀÍÆ÷»á×Ô¶¯ÎªÓû§·ÖÅÉÒ»¸öΨһµÄ session_id£¬²¢½«¸Ã session_id ÉúÑÄÔÚÓû§µÄä¯ÀÀÆ÷ÖС£
µ±Óû§¾ÙÐÐÆäËû²Ù×÷ʱ£¬Ð§ÀÍÆ÷»áƾ֤ä¯ÀÀÆ÷ÖÐµÄ session_id ÕÒµ½¶ÔÓ¦µÄ session£¬È»ºó¶ÁÈ¡»òÐÞ¸Ä session ÖÐÉúÑĵÄÊý¾Ý¡£
Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
µ±Óû§¹Ø±Õä¯ÀÀÆ÷ʱ£¬Ð§ÀÍÆ÷»áÏú»Ù¸ÃÓû§µÄ session£¬ÏìÓ¦µÄ session ÎļþÒ²»á±»É¾³ý¡£
¶þ¡¢É¨³ý session µÄÒªÁì
ÓÐʱ£¬ÎÒÃÇÐèҪɨ³ý session£¬ÀýÈçÓû§µÇ³ö¡¢Çл»Óû§µÈÇéÐΡ£ÏÂÃæÓÐÈýÖÖ³£ÓõÄÒªÁ죬¿ÉÒÔɨ³ý session
ʹÓà Session ÀàµÄ destroy ÒªÁì
thinkphp5 ÌṩÁËÒ»¸ö Session À࣬¿ÉÒÔÀû±ãµØ²Ù×÷ session¡£Í¨¹ýʹÓà destroy ÒªÁ죬Äú¿ÉÒÔɨ³ýÌض¨µÄ»á»°¡£
ʾÀý´úÂëÈçÏ£º
use think\facade\Session; // ɨ³ýÃûΪ user_info µÄ session Session::destroy('user_info');
µÇ¼ºó¸´ÖÆ
ʹÓà Session ÀàµÄ clear ÒªÁì
ʹÓøÃÒªÁì¿ÉÒÔɨ³ýËùÓÐµÄ session¡£
ʾÀý´úÂëÈçÏ£º
use think\facade\Session; //ɨ³ýËùÓÐsession Session::clear();
µÇ¼ºó¸´ÖÆ
Ö±½Óɾ³ý session Îļþ
ÔÚĬÈÏÇéÐÎÏ£¬thinkphp5 »á½« session ÎļþÉúÑÄÔÚ runtime/session Ŀ¼Ï¡£ÒªÉ¨³ý session£¬ÎÒÃÇ¿ÉÒÔÖ±½Óɾ³ýÖ¸¶¨Ä¿Â¼ÖÐµÄ session Îļþ¡£
ʾÀý´úÂëÈçÏ£º
unlink('./runtime/session/sess_session_id');
µÇ¼ºó¸´ÖÆ
ÆäÖУ¬session_id ÊÇÖ¸ÐèҪɾ³ýµÄ session µÄ id¡£
ÒÔÉϾÍÊÇÔõôʹÓÃthinkphp5ɨ³ýsessionµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡