2012-05-22 49 views
1
function get_user_id() 
{ 
    global $cookie; 
    $userid = NULL; 

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

    return $userid; 
} 

为什么用户标识即使登录也会返回null?获取用户ID Prestashop

+0

你把这个代码,你创建的模块或控制器放在哪里? – romainberger

回答

0

$ PARAMS [ '饼干'] - > id_customer

,你不应该使用全局变量。

6

如果使用的Prestashop 1.5使用Context对象,而不是:

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

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

如果没有从父类继承上下文。