Model_Auth_User_Token::create_token PHP 메소드

create_token() 공개 메소드

Finds a new unique token, using a loop to make sure that the token does not already exist in the database. This could potentially become an infinite loop, but the chances of that happening are very unlikely.
public create_token ( ) : string
리턴 string
    public function create_token()
    {
        while (TRUE) {
            // Create a random token
            $token = text::random('alnum', 32);
            // Make sure the token does not already exist
            if (!Jelly::select('user_token')->where('token', '=', $token)->count()) {
                // A unique token has been found
                return $token;
            }
        }
    }