php鐨勪細璇濇帶鍒舵妧鏈 session涓巆ookie

绠杩癱ookie鍜宻ession鐨勫尯鍒強鍚勮嚜鐨勫伐浣滄満鍒讹紝鍌ㄥ瓨浣嶇疆绛夛紝绠杩癱ookie鐨勪紭缂虹偣銆

鎵撲竴涓瘮鏂癸紝鐢ㄦ埛鍘昏秴甯備拱涓滆タ锛岀劧鍚庡姙鐞嗕簡涓寮犱細鍛樺崱锛岄偅涔堣秴甯傚氨鍙互鐞嗚В涓烘湇鍔″櫒锛岀敤鎴峰彲浠ョ悊瑙d负瀹㈡埛绔紝鑰屼細鍛樺崱灏卞彲浠ョ悊瑙d负cookie锛屼細鍛樺崱閲岄潰瀛樺偍鐫鐢ㄦ埛淇℃伅銆

cookie鐨勬搷浣

setcookie($name,$value,$expire,$path,$domain,$secure)
$_COOKIE
瀛樻暟缁 setcookie(‘a[b]’,’val’)
鍒犻櫎 setcookie($name,”,time-1000)

cookie鐨勪紭缂虹偣

浼樼偣锛氫笉浼氬崰鐢ㄦ湇鍔″櫒璧勬簮锛屾晥鐜囬珮
缂虹偣锛氫笉寤鸿灏嗘晱鎰熶俊鎭瓨鍌ㄥ湪cookie锛岀敤鎴峰彲浠ョ鐢╟ookie锛屽垯鏃犳硶淇濆瓨鐢ㄦ埛淇℃伅

session涓巆ookie鐨勮仈绯 SessionID

杩樻槸鍘昏秴甯傦紝瓒呭競缁欑敤鎴峰姙浜嗕竴寮犵數瀛愬崱锛屾瘡娆″彧闇瑕佽鏄庣敤鎴风殑浼氬憳鍗″彿鐮侊紝鎴栬呮槸鎵嬫満韬唤璇佷粈涔堢殑锛岄偅涔堣繖涓韩浠借瘉灏辩浉褰撲簬SessionID
鍥犱负鏈夊彲鑳藉鎴风浼氱鐢╟ookie锛屾墍浠ュ彲浠ラ氳繃鍦╱rl涓婃嫾鎺ワ紝濡

<a href="1.php?<?php echo session_name().'='.session_id();?>"></a>

鎴栬呮洿绠鍗曠殑鏂规硶

<a href="1.php?<?php echo SID;?>"></a>

鑰屼笖SID鍙湁鍦╟ookie琚鐢ㄧ殑鎯呭喌涓嬫墠浼氳皟鐢ㄥ埌銆

鎵浠ヨ锛宻ession鐨勮鍙栦篃鏄渶瑕乧ookie涓婇潰鐨凷essionID

session鐨勬搷浣

瑕佷娇鐢╯ession棣栧厛瑕乻ession_start銆傜劧鍚庣洿鎺ユ搷浣$_SESSION灏卞彲浠ヤ簡
閿姣乻ession $_SESSION = [];鎴栬卻ession_destory();

session鐨勯厤缃 (php.ini)

session.auto_start 鏄惁鑷姩寮鍚痵ession_start
session.cookie_domian 瀛樺偍cookie鐨勬湁鏁堝煙
session.cookie_lifetime
session.cookie_path
session.name(榛樿鏄疨HPSESSID)
session.save_path(榛樿瀛樺偍璺緞)
session.use_cookies(鏄惁浣跨敤cookie鏉ヤ紶閫抯essionid)
session.use_trans_sid
session.gc_probability (鍨冨溇鍥炴敹鏈哄埗) =1 鏈変竴娆℃竻鐞嗙殑鏈轰細
session.gc_divisor = 100 姣忚闂竴鐧炬
session.gc_maxlifetime(鏈澶х敓鍛藉懆鏈) =1440 濡傛灉瓒呰繃25鍒嗛挓
seaaion.save_handler 鍙互鍌ㄥ瓨鍒皉edis,mysql绛 鍦ㄨ繖閲岄厤缃

session鐨勪紭缂虹偣

浼樼偣瀹夊叏锛岄兘鏄瓨鍌ㄥ湪鏈嶅姟鍣ㄩ噷闈
缂虹偣 鍗犵敤鏈嶅姟鍣ㄧ鐩

璐熻浇鍧囪 涓巗ession

鍋囪澶氬彴鏈嶅姟鍣,session鐨勫瓨鍌ㄥ氨浼氭槸涓涓棶棰橈紝濡傚湪涓鍙版湇鍔″櫒鐧婚檰鍚庝骇鐢熺殑session锛屽鏋滆璐熻浇鍧囪 杞鍒板彟澶栦竴鍙版湇鍔″櫒锛岄偅涔堣繖涓櫥闄嗗氨鏃犳晥浜嗭紝鎵浠ラ渶瑕佹妸session 瀛樺偍鍒板彟澶栫殑鍦版柟锛屽mysql锛宮emcache锛宺eids绛
鍙互浣跨敤session_set_save_handler()

All posts

Other pages


Deprecated: 鏂囦欢 娌℃湁 comments.php 鐨勪富棰 鑷増鏈 3.0.0 璧峰凡寮冪敤锛屼笖娌℃湁鍙敤鐨勬浛浠c 璇峰湪鎮ㄧ殑涓婚涓寘鍚竴涓 comments.php 妯℃澘銆 in /www/wwwroot/liguoqi.site/wp-includes/functions.php on line 6078

鍙戣〃鍥炲

鎮ㄧ殑鐢靛瓙閭鍦板潃涓嶄細琚叕寮銆 蹇呭~椤瑰凡鐢 * 鏍囨敞