尊龙凯时人生就是搏

ÔõôÐÞ¸ÄThinkPHP6ÖеÄSessionÉèÖÃ

Ò»¡¢SessionÏÈÈÝ

SessionÊÇÒ»ÖÖ´æ´¢Óû§ÐÅÏ¢µÄÊý¾Ý½á¹¹£¬ÔÚWebÓ¦ÓóÌÐòÖÐÉúÑÄÔÚWebЧÀÍÆ÷ÉÏ¡£µ±Óû§ä¯ÀÀÍøվʱ£¬Ð§ÀÍÆ÷»áÌìÉúÒ»¸öSession£¬²¢½«ÆäID·¢Ë͸ø¿Í»§¶Ëä¯ÀÀÆ÷¡£ä¯ÀÀÆ÷ÔÚ·µ»ØÇëÇóʱ£¬»á´øÉϸÃSessionµÄID£¬Ð§ÀÍÆ÷¾Í¿ÉÒÔͨ¹ý¸ÃIDÕÒµ½¸ÃÓû§µÄSession£¬²¢´ÓSessionÖжÁÈ¡»òÐÞ¸ÄÓû§µÄÐÅÏ¢¡£SessionµÄ×÷ÓÃÖ÷Òª¿ÉÒÔ¹éÄÉΪÒÔϼ¸¸ö·½Ã棺

´æ´¢Óû§ÐÅÏ¢¡£ºÃ±ÈÓû§µÄµÇ¼״̬¡¢¹ºÎï³µÄÚÈÝ¡¢±íµ¥Êý¾ÝµÈ¡£

ʵÏÖ¿çÒ³ÃæÊý¾Ý¹²Ïí¡£ºÃ±ÈÔÚ¶à¸öÒ³ÃæÖ®¼ä¹²ÏíÓû§ÐÅÏ¢¡£

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡± £»

È·±£Ã¿¸öÓû§¶¼ÓÐ×ÔÁ¦µÄÊý¾Ý´æ´¢¿Õ¼ä¡£

ÔÚThinkPHP6ÖУ¬SessionĬÈÏʹÓÃÁËPHPµÄSession»úÖÆʵÏÖ£¬¿ª·¢Ö°Ô±¿ÉÒÔÔÚÓ¦ÓóÌÐòÖÐÀû±ãµØ²Ù×÷Session¡£

¶þ¡¢SessionÉèÖÃ

SessionµÄÉèÖÃÔÚThinkPHP6ÖÐÖ÷ÒªÉæ¼°ÒÔϼ¸¸ö²ÎÊý£º

session_name£ºSessionÃû³Æ¡£Ä¬ÒÔΪPHPSESSID¡£

expire£ºSessionÓâÆÚʱ¼ä¡£Ä¬ÒÔΪ1440Ãë¡£

use_trans_sid£ºÊÇ·ñÆôÓÃSIDת´ï·½·¨¡£Ä¬ÒÔΪ¹Ø±Õ¡£

auto_start£ºÊÇ·ñ×Ô¶¯Æô¶¯Session¡£Ä¬ÒÔΪ¹Ø±Õ¡£

path£ºSessionÉúÑÄ·¾¶¡£Ä¬ÒÔΪϽµµÍÙʱĿ¼¡£

domain£ºSessionÓòÃû¡£Ä¬ÒÔΪ¿Õ¡£

secure£ºÊÇ·ñÆôÓÃÇå¾²´«Ê䡣ĬÒÔΪ¹Ø±Õ¡£

httponly£ºÊÇ·ñÆôÓÃHttpOnly¡£Ä¬ÒÔΪ¹Ø±Õ¡£

ÈôÊÇÐèÒªÐÞ¸ÄSessionµÄÉèÖã¬ÔÚThinkPHP6ÖпÉÒÔͨ¹ýconfigĿ¼ÏµÄsession.phpÎļþ¾ÙÐÐÉèÖá£Ïêϸ²Ù×÷ÈçÏ£º

½øÈëconfigĿ¼£¬ÕÒµ½session.phpÎļþ¡£

ÐÞ¸Äsession.phpÎļþÖеÄÏà¹ØÉèÖòÎÊý¡£ºÃ±È£º

return [
    // session name
    'name'           => 'think_session',
    // session auto start
    'auto_start'     => true,
    // session type
    'type'           => '',
    // expire time
    'expire'         => 86400,
    // use database
    'use_database'   => false,
    // data compression
    'data_compress'  => false,
    // cache prefix
    'prefix'         => '',
    // cache expire time
    'cache_expire'   => null,
    // session id
    'id'             => '',
    // session path
    'path'           => '',
    // session domain
    'domain'         => '',
    // session secure
    'secure'         => false,
    // session httponly
    'httponly'       => false,
    // session redis connection
    'redis_connection' => 'session_redis',
    // redis handler
    'redis_handler'  => '',
    // redis session key prefix
    'redis_prefix'   => '',
];

µÇ¼ºó¸´ÖÆ

ÉúÑÄÎļþ²¢¹Ø±Õ¡£

Èý¡¢SessionµÄʹÓÃ

ÔÚThinkPHP6ÖУ¬SessionµÄʹÓúÜÊǼòÆÓ£¬¿ª·¢Ö°Ô±¿ÉÒÔͨ¹ýÒÔÏ·½·¨À´¶ÁÈ¡ºÍдÈëSessionÖеÄÊý¾Ý£º

¶ÁÈ¡SessionÊý¾Ý£º

$request = Request::instance();
$session = $request->session();
$value   = $session->get('key');

µÇ¼ºó¸´ÖÆ

дÈëSessionÊý¾Ý£º

$request = Request::instance();
$session = $request->session();
$session->set('key', 'value');

µÇ¼ºó¸´ÖÆ

ÔÚÏÖʵ¿ª·¢ÖУ¬¿ª·¢Ö°Ô±¿ÉÒÔƾ֤ӪҵÐèÇó£¬×Ô½ç˵SessionµÄÏà¹ØÉèÖã¬ÒÔʵÏÖÔ½·¢ÎÞаºÍ¸ßЧµÄÊý¾Ý´æ´¢ºÍÖÎÀí¡£

ÒÔÉϾÍÊÇÔõôÐÞ¸ÄThinkPHP6ÖеÄSessionÉèÖõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí£¬°æȨÕùÒéÓë±¾Õ¾Î޹أ¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í尊龙凯时人生就是搏ÂËÓÍ»úÍø¹Ù·½Ì¬¶È£¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ£¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢£¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢£¬ÇëÄúÁ¬Ã¦ÁªÏµ尊龙凯时人生就是搏ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎ壬9:30-18:30£¬½ÚãåÈÕÐÝÏ¢

QR code
sitemap¡¢ÍøÕ¾µØͼ