简体   繁体   中英

Calling Cake PHP UserID on outside PHP file

Actually am trying to get user id from cakephp, php file was placed outside folder. How can I get user ID from 'users' table.

function get_user_id() 
{
    $userid = NULL;

    if (!empty($_SESSION['userid']))
    {
        $userid = $_SESSION['userid'];
    }

    return $userid;
}

There is no such thing as "cakephp" database.

What you probably mean is that a SQL database is being used by a CakePHP application.

Cake provides config files where database details are indicated, and Cake engine will use these details to interact with the database (create new users, update user's data, etc).

Then if you want to access the same database with an external PHP script that doesn't know about the config files that CakePHP uses you need to use the methods that PHP have to access the database and throw a SQL query against it (SELECT...)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM