尊龙凯时人生就是搏

thinkphpեȡÓû§Öظ´µÇ¼

Ëæ×Å»¥ÁªÍøµÄÒ»Ö±Éú³¤ £¬Ô½À´Ô½¶àµÄÍøÕ¾ºÍÓ¦ÓóÌÐòÒªÇóÓû§¾ÙÐÐ×¢²áºÍµÇ¼ £¬ÒÔ±ãÌṩԽ·¢¸öÐÔ»¯ºÍÇå¾²µÄЧÀÍ¡£¿ÉÊÇ £¬±£´æÒ»¸öÎÊÌâ £¬ÓÐЩÓû§»áͬʱÔÚ¶à¸ö×°±¸»òä¯ÀÀÆ÷ÖеǼͳһ¸öÕʺŠ£¬Õâ¿ÉÄܻᵼÖÂÊý¾ÝÇå¾²·½ÃæµÄÎÊÌâ £¬ÀýÈçÐÅÏ¢×ß© £¬»òÕß·ºÆðÊý¾Ý³åÍ»µÈÎÊÌâ¡£

Òò´Ë £¬ÔÚÏÖʵµÄÓ¦Óó¡¾°ÖÐ £¬ÎÒÃÇÐèÒª½â¾öÕâ¸öÎÊÌâ £¬¼´Õ¥È¡Í³Ò»¸öÓû§ÔÚ¶à¸ö×°±¸»òä¯ÀÀÆ÷ÖÐͬʱµÇ¼ͳһ¸öÕʺÅ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃThinkPHP¿ò¼ÜÀ´ÊµÏִ˹¦Ð§¡£

Ê×ÏÈ £¬ÎÒÃÇÐèҪȷ±£Óû§ÔڵǼʱÌìÉúÒ»¸öΨһµÄÉí·Ý±êʶ·û £¬Õâ¸ö±êʶ·û¿ÉÒÔÓÃÊý¾Ý¿âÖеÄÖ÷¼ü»òÕßÊÇËæ»úÌìÉúµÄÒ»¸ö×Ö·û´®×÷ΪÉí·Ý±êʶ·û¡£ÔÚ¸ÃÓû§¾ÙÐеǼʱ £¬ÎÒÃÇÐèÒª½«¸Ã±êʶ·û´æ´¢ÔÚSession»òÕßCookieÖÐ £¬Àû±ãºóÐøÑé֤ijһ¸öÓû§ÊÇ·ñÒѾ­µÇ¼¡£

µ±Óû§µÇ¼ʱ £¬ÎÒÃÇÐèÒª´ÓÊý¾Ý¿âÖÐÅÌÎʸÃÓû§ÊÇ·ñÒѾ­±£´æÓÐÓõĵǼ±êʶ·û £¬ÈôÊDZ£´æ £¬Ôò˵Ã÷¸ÃÓû§ÒѾ­ÔÚÆäËû×°±¸»òä¯ÀÀÆ÷ÖеǼÁ˸ÃÕʺŠ£¬´ËʱÐèÒªÌáÐÑÓû§Í˳öÆäËûµÄµÇ¼»á»° £¬²¢ÖØеǼ¡£

´úÂëʾÀýÈçÏ£º

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

/**
 * µÇ¼ÑéÖ¤
 */
public function login(){
    $username = I('post.username');
    $password = I('post.password');
    $user = M('User')->where(array('username'=>$username))->find();
    if (!$user) {
        $this->error('Óû§²»±£´æ£¡');
    }elseif(md5($password.$user['salt']) !== $user['password']){
        $this->error('ÃÜÂë¹ýʧ£¡');
    }else{
        // ÅжÏÓû§ÊÇ·ñÒѾ­µÇ¼
        $uid = $user['id']; // »ñÈ¡Óû§ID
        $session_uid = session('uid'); // ´ÓSessionÖлñÈ¡Óû§ID
        $session_sid = session('sid'); // ´ÓSessionÖлñÈ¡µÇ¼±êʶ·û
        if($uid == $session_uid && $session_sid){ // ÅжÏÓû§ÊÇ·ñÒѾ­µÇ¼
            $this->error('ÄúÒѾ­ÔÚÆäËûÉè±¹ØÁ¬Ç¼£¬ÇëÏÈÍ˳öÆäËûµÄµÇ¼»á»°£¡');
        }else{
            // ÌìÉúеÄÉí·Ý±êʶ·û
            $sid = md5(uniqid(mt_rand(), true)); // ÌìÉúËæ»ú×Ö·û´®×÷ΪÉí·Ý±êʶ·û
            session('uid', $uid); // ½«Óû§ID´æ´¢µ½SessionÖÐ
            session('sid', $sid); // ½«µÇ¼±êʶ·û´æ´¢µ½SessionÖÐ
            $this->success('µÇ¼Àֳɣ¡');
        }
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÒÔÉÏ´úÂëÖÐ £¬ÎÒÃÇÊ×ÏÈ´ÓÊý¾Ý¿âÖÐÅÌÎʸÃÓû§µÄÐÅÏ¢ £¬È»ºóÑéÖ¤Óû§µÄÕʺźÍÃÜÂëÊÇ·ñ׼ȷ¡£ÈôÊÇÑé֤ͨ¹ý £¬ÄÇô¾ÍÅжÏÓû§ÊÇ·ñÒѾ­ÔÚÆäËû×°±¸»òä¯ÀÀÆ÷ÖеǼÁ˸ÃÕʺŠ£¬ÈôÊÇÓÐ £¬ÔòÌáÐÑÓû§Í˳öÆäËûµÄµÇ¼»á»°¡£

ÈôÊÇÓû§Ã»ÓÐÔÚÆäËû×°±¸»òä¯ÀÀÆ÷ÖеǼ¸ÃÕʺŠ£¬ÄÇô¾ÍÌìÉúÒ»¸öеÄÉí·Ý±êʶ·û £¬²¢½«Óû§IDºÍµÇ¼±êʶ·û´æ´¢µ½SessionÖС£ÕâÑù £¬Ï´ÎÓû§¾ÙÐвÙ×÷ʱ £¬ÎÒÃǾͿÉÒÔÑéÖ¤Óû§µÄÉí·ÝÊÇ·ñ׼ȷ¡£

ÔÚ´úÂëʵÏÖµÄÀú³ÌÖÐ £¬ÎÒÃÇʹÓÃÁËSessionÀ´´æ´¢Óû§µÄµÇ¼ÐÅÏ¢ £¬ÕâÑù×öÓÐÒ»¸öÎÊÌâ £¬¼´µ±Óû§¹Ø±Õä¯ÀÀÆ÷ʱ £¬SessionÖд洢µÄÐÅÏ¢»á±»É¾³ý £¬´ËʱÓû§ÐèÒªÖØоÙÐеǼ²Ù×÷¡£Òò´Ë £¬ÔÚÏÖʵµÄÓ¦ÓÃÖÐ £¬ÎÒÃÇ¿ÉÒÔ½«SessionÖеÄÐÅÏ¢´æ´¢µ½Êý¾Ý¿âÖлòÕßʹÓÃRedisµÈ»º´æ¹¤¾ß¾ÙÐÐÖÎÀí £¬ÕâÑù¿ÉÒÔÓÐÓõؽâ¾öSessionÓâÆÚµÄÎÊÌâ¡£

×ܽ᣺

±¾ÎÄÏÈÈÝÁËÔõÑùʹÓÃThinkPHP¿ò¼ÜÀ´Õ¥È¡Í³Ò»¸öÓû§ÔÚ¶à¸ö×°±¸»òä¯ÀÀÆ÷ÖÐͬʱµÇ¼ͳһ¸öÕʺŵÄÒªÁ졣ͨ¹ýÑéÖ¤Óû§µÇ¼ʱµÄÉí·Ý±êʶ·û £¬ÎÒÃÇ¿ÉÒÔÓÐÓõرÜÃâÊý¾ÝÇå¾²·½ÃæµÄÎÊÌâ¡£ÔÚÏÖʵӦÓÃÖÐ £¬ÎÒÃÇ»¹¿ÉÒÔ¶ÔSessionµÄÖÎÀí¾ÙÐÐÓÅ»¯ £¬ÒÔÌá¸ßÓ¦ÓõÄÐÔÄܺÍÎȹÌÐÔ¡£

ÒÔÉϾÍÊÇthinkphpեȡÓû§Öظ´µÇ¼µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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