Thiago Quadros Posted June 29, 2011 Share Posted June 29, 2011 Hi,this is my last choice. I'm trying seek information in full internet.Well, going to the question:I'm trying get the ID of the current Employee logged. All method type, returned me a void sentence.Example:$_POST['id_employee']$cookie->id_employeeand many others bad choices of codes.Please, I'm needing help!source code is in attachment.tks... ab_prod.php Link to comment Share on other sites More sharing options...
Richard S Posted June 29, 2011 Share Posted June 29, 2011 $cookie->id_employeeShould worked, if I remember good, maybe you forget to make it global in the method? Link to comment Share on other sites More sharing options...
MahmutGulerce Posted June 29, 2011 Share Posted June 29, 2011 hi;could you try print_r($cookie); Other hand you must set cookie to global in class functions declarations Like function SampleFunction ($arg) { global $cookie; // Now you can use cookie // return (int)$cookie->id_employee; } Link to comment Share on other sites More sharing options...
Thiago Quadros Posted June 29, 2011 Author Share Posted June 29, 2011 very, very, very thanks.The "global" reserved word that is a great solution.Thanks. Link to comment Share on other sites More sharing options...
MahmutGulerce Posted June 29, 2011 Share Posted June 29, 2011 very, very, very thanks.The "global" reserved word that is a great solution.Thanks. I'm so glad it had worked Link to comment Share on other sites More sharing options...
Prestadget Posted November 22, 2012 Share Posted November 22, 2012 I'm so glad it had worked Sorry for the old post, but I came accros it from Google, so, a better anwser : Prestashop uses 2 cookies, one for Front and one for Backoffice. The backoffice cookie is named "psAdmin", encoded with a MD5 and contains the employee_id. So your solution is only working under /admin folder ! If you want to retrieve the employee_id outside it, you need to create a new Cookie('psAdmin') Link to comment Share on other sites More sharing options...
Ricardo Vigatti Posted September 20, 2013 Share Posted September 20, 2013 Sorry for the old post, but I came accros it from Google, so, a better anwser : Prestashop uses 2 cookies, one for Front and one for Backoffice. The backoffice cookie is named "psAdmin", encoded with a MD5 and contains the employee_id. So your solution is only working under /admin folder ! If you want to retrieve the employee_id outside it, you need to create a new Cookie('psAdmin') Prestadget, i can't understand what you told about the backoffice cookie, can you please help us on how to use it ? For now, i'm using the "global $cookie" and it's working Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 23, 2014 Share Posted June 23, 2014 Hi I am trying to use this for my standarad php coding but I am unable to access this id_employee variable..I am trying to use it for standard php code. I want to save the id_employee in a new $id variable please help. Link to comment Share on other sites More sharing options...
JoelWebsites Posted June 23, 2014 Share Posted June 23, 2014 $id = ((int)$cookie->id_employee); this returns me zero value Link to comment Share on other sites More sharing options...
vekia Posted June 25, 2014 Share Posted June 25, 2014 you have to define global cookie. global $cookie; $cokie->id_employee; Link to comment Share on other sites More sharing options...
karthiiiiiiiiiik Posted September 1, 2014 Share Posted September 1, 2014 how to do i get the employee id in tpl file ... Link to comment Share on other sites More sharing options...
aquahuang Posted February 3, 2016 Share Posted February 3, 2016 put this {$employee->id} in .tpl Link to comment Share on other sites More sharing options...
serfer2 Posted March 28, 2016 Share Posted March 28, 2016 For Prestashop >= 1.5 you must use "Context" class (read the docs). In example (inside a module code): $employee_id = $this->context->employee->id; or: $ctx = Context::getContext(); $emp_id = (int)$ctx->employee->id; Hope it helps ;-) Link to comment Share on other sites More sharing options...
Klemart3D Posted July 6, 2016 Share Posted July 6, 2016 print_r($this->context->employee->id); Fatal error: Using $this when not in object context Link to comment Share on other sites More sharing options...
Jihene Heni Posted April 2, 2018 Share Posted April 2, 2018 comment recuperer id_employee pour prestashop 1.7 Link to comment Share on other sites More sharing options...
Pierre Belin Posted October 28, 2019 Share Posted October 28, 2019 On 3/28/2016 at 9:53 AM, serfer2 said: For Prestashop >= 1.5 you must use "Context" class (read the docs). In example (inside a module code): $employee_id = $this->context->employee->id; It's exactly the same in PrestaShop 1.7. If you want to get the employee ID in a hook, you have to call it that way : $id_employee = Context::getContext()->employee->id; Link to comment Share on other sites More sharing options...
oldmanxxxv Posted December 9, 2021 Share Posted December 9, 2021 Hi there. Is there any any of you who knows how to get in Prestashop 1.7.8 in admin area, order template twig page the employee id and the token generated for that page? I'm kind of stuck here. Thanks! Link to comment Share on other sites More sharing options...
ZiedDams Posted January 13, 2022 Share Posted January 13, 2022 On 10/28/2019 at 4:54 AM, Pierre Belin said: It's exactly the same in PrestaShop 1.7. If you want to get the employee ID in a hook, you have to call it that way : $id_employee = Context::getContext()->employee->id; employee variable is 'NULL' while I'm a superAdmin Connected Link to comment Share on other sites More sharing options...
Inter Svetainė Posted November 15, 2023 Share Posted November 15, 2023 On 1/13/2022 at 10:40 AM, ZiedDams said: employee variable is 'NULL' while I'm a superAdmin Connected Outside Prestashop You have to add admin cookie. Use this code. <?php require_once dirname(__FILE__).'/config/config.inc.php'; $cookie = new Cookie('psAdmin', '', (int)Configuration::get('PS_COOKIE_LIFETIME_BO')); if (isset($cookie->id_employee) && $cookie->id_employee) { echo 'ID Employee: '.$cookie->id_employee; } else { echo 'No employee logged in.'; } Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now