getting userid in 3rd party php file
PermalinkI need to get the userid of the currently loggedin user into a an variable. In old concrete it was in a session, but after the security system was changed i can't get it from the session anymore.
As the php file is not loaded from concrete5 i can't just call
$u = new User();
echo $u->getUserID();
How do i get the information?
Maybe not a beatiful solution, but it works. :)
if (!empty($_COOKIE['CONCRETE5'])) {
$data = file_get_contents(dirname(dirname(__FILE__)).'/files/tmp/sess_'.$_COOKIE['CONCRETE5']);
if (!empty($data)) {
session_decode($data);
}
}
if (!empty($_SESSION['uID'])) {
$userid = $_SESSION['uID'];