CakePHP MD5 va Cake session string

Bu satrda har bir kishi muammo ko'rishi mumkin: $ emailtoken = md5 ($ user ['User'] ['parol']; CAKE_SESSION_STRING);

As it gives the following error: Use of undefined constant CAKE_SESSION_STRING - assumed 'CAKE_SESSION_STRING'

U hali ham bir token yaratadi, ammo bu xatoga yo'l qo'yadi va keyin tokenni ishlatganda uni noto'g'ri deb aytadi: /

Mana to'liq funktsiya:

        function admin_resetpassword ( $token = null )
        {
           //User submits their email address
            if (!empty($this->data['User']['email']))
            { 
               //user submitted initial form 
                $user = $this->User->findByEmail($this->data['User']['email']); 
                if (empty($user))
                { 
                    $this->Session->setFlash('Unknown email.'); 
                    return;  
                }
                else
                { 
                    $emailtoken = md5($user['User']['password'].CAKE_SESSION_STRING); 
                   //send email (temp flash to test code) 
                    $this->Session->setFlash($emailtoken); 
                    return; 
                } 
            }
// If the token is not empty on the url
        if (!empty($token))
        { 
            $user = $this->User->find(array("MD5(User.password + '".CAKE_SESSION_STRING."')"=>$token));

            if (empty($user))
            { 
                $this->Session->setFlash('Invalid token.'); 
                return; 
            } 

            if (!empty($this->data['User']['password']))
            { 
                $user['User']['password'] = $this->data['User']['password']; 
                $this->user->save($user); 
                $this->Session->setFlash('New password set.'); 
                $this->redirect('/'); 
            } 

            $this->set('token', $token); 
            $this->render('newpassword2'); 
        } 


    }
0

1 javoblar

the problem is CAKE_SESSION_STRING is not defined (as stated in the error). If you want to get the salt or cipherSeed, use Configure::read('Security.salt'); or $this-Session->id; But you know this session id is lost after certain inactivity period, right? You won't be able to get that session id back later on (unless you save it somewhere).

0
qo'shib qo'ydi
PhP |BotsUz
PhP |BotsUz
93 ishtirokchilar

Phpni o'rganishni Hohlasangiz https://t.me/joinchat/AAAAAE-KRc5dd5tPMmGmWA A'zo bo'lin