Kek Vpsdua
Kek Vpsdua

Reputation: 21

Get User ID Prestashop

function get_user_id() 
{
    global $cookie;
    $userid = NULL;

    if (isset($cookie->id_customer))
    {
        $userid = $cookie->id_customer;
    }

    return $userid;
}

Why the user ID keep return null even with login?

Upvotes: 2

Views: 12060

Answers (2)

klimpond
klimpond

Reputation: 766

If using Prestashop 1.5 use Context object instead:

$this->context->customer->id;

or

Context::getContext()->customer->id

If there is no context inherited from parent classes.

Upvotes: 9

Eduardo Moniz
Eduardo Moniz

Reputation: 2115

$params['cookie']->id_customer

and you shouldnt use global variables.

Upvotes: 0

Related Questions