Create a session in custom Prestashop file

1

Is it possible to create a session from a custom prestashop file? I have restricted from the frontController browsing the store if a user does not have a session.

 if (!$this->context->customer->isLogged() && $this->php_self !=  'authentication' && $this->php_self != 'password'){
         Tools::redirect('index.php?controller=authentication?back=my-account');
    }

Now I need to access the certain methods of the tool from a custom file (if I include the file init.php first, check the status of my session and redirect me to login), there is a way to create a session before including this file?, Thanks.

    
asked by Jose A. 29.08.2018 в 16:22
source

1 answer

0

this serves to create a session, in case it is useful

$contexcookie= context::getContext()->cookie;
$contexcustomer= context::getContext()->customer;
$customer = new Customer((int)($customer->id));
$contexcookie->id_customer = (int)($customer->id);
$contexcookie->customer_lastname = $customer->lastname;
$contexcookie->customer_firstname = $customer->firstname;
$contexcookie->logged = 1;
$customer->logged = 1;
$contexcookie->is_guest = $customer->isGuest();
$contexcookie->passwd = $customer->passwd;
$contexcookie->email = $customer->email;
// Add customer to the context
$contexcustomer = $customer;
    
answered by 31.08.2018 в 04:38