Jump to content

get the id of the current employee


rayrayrugby
 Share

Recommended Posts

Hi everybody,

 

I'm currently trying to get the id of the current employee from an outside php file.

I did it like that but it doesn't work :

<?php

    require_once(dirname(__FILE__).'/../../config/config.inc.php');
    require_once(dirname(__FILE__).'/../../config/settings.inc.php');
    require_once(dirname(__FILE__).'/../../classes/Cookie.php');
    
    $cookie = new Cookie('psAdmin');

    $id_employee = $cookie->id_employee;
    $profile = $cookie->profile;

    echo $id_employee;
    echo $profile;
    die();

?>

Could somebody help me please ?

Share this post


Link to post
Share on other sites

You should use Context object. 

<?php
 
    require_once(dirname(__FILE__).'/../../config/config.inc.php');
    require_once(dirname(__FILE__).'/../../config/settings.inc.php');
    
    $context = Context::getContext();

    if (isset($context->employee) && $context->employee->id > 0) {
        $id_employee = $context->employee->id;
        echo "ID Employee: $id_employee";
    } else
        echo "No employee logged in.";

    die();
 
?>
  • Like 1

Share this post


Link to post
Share on other sites

  • 7 years later...
On 10/29/2014 at 4:29 PM, cristic said:

You should use Context object. 

<?php
 
    require_once(dirname(__FILE__).'/../../config/config.inc.php');
    require_once(dirname(__FILE__).'/../../config/settings.inc.php');
    
    $context = Context::getContext();

    if (isset($context->employee) && $context->employee->id > 0) {
        $id_employee = $context->employee->id;
        echo "ID Employee: $id_employee";
    } else
        echo "No employee logged in.";

    die();
 
?>

i try it this code but t give me no employee login in while im logged in , any idea ?

Share this post


Link to post
Share on other sites

  • 1 month later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More